Fix checking of index.html (#85016)
This commit is contained in:
@@ -99,6 +99,9 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
if (stringArg('base-href') != null && !(stringArg('base-href').startsWith('/') && stringArg('base-href').endsWith('/'))) {
|
||||
throwToolExit('base-href should start and end with /');
|
||||
}
|
||||
if (!flutterProject.web.existsSync()) {
|
||||
throwToolExit('Missing index.html.');
|
||||
}
|
||||
if (!globals.fs.currentDirectory
|
||||
.childDirectory('web')
|
||||
.childFile('index.html')
|
||||
|
||||
@@ -28,9 +28,6 @@ Future<void> buildWeb(
|
||||
bool nativeNullAssertions,
|
||||
String baseHref,
|
||||
) async {
|
||||
if (!flutterProject.web.existsSync()) {
|
||||
throwToolExit('Missing index.html.');
|
||||
}
|
||||
final bool hasWebPlugins = (await findPlugins(flutterProject))
|
||||
.any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
|
||||
final Directory outputDirectory = globals.fs.directory(getWebBuildDirectory());
|
||||
|
||||
@@ -14,9 +14,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/build.dart';
|
||||
import 'package:flutter_tools/src/commands/build_web.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:flutter_tools/src/web/compile.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -50,18 +48,12 @@ void main() {
|
||||
|
||||
testUsingContext('Refuses to build for web when missing index.html', () async {
|
||||
fileSystem.file(fileSystem.path.join('web', 'index.html')).deleteSync();
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
|
||||
|
||||
expect(buildWeb(
|
||||
project,
|
||||
fileSystem.path.join('lib', 'main.dart'),
|
||||
BuildInfo.debug,
|
||||
false,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
), throwsToolExit());
|
||||
expect(
|
||||
() => runner.run(<String>['build', 'web', '--no-pub']),
|
||||
throwsToolExit(message: 'Missing index.html.')
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
|
||||
Reference in New Issue
Block a user