Unverified Commit 49c08b73 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by GitHub

Fix checking of index.html (#85016)

parent 1ac209c2
......@@ -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);
expect(buildWeb(
project,
fileSystem.path.join('lib', 'main.dart'),
BuildInfo.debug,
false,
null,
true,
true,
null,
), throwsToolExit());
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(
() => runner.run(<String>['build', 'web', '--no-pub']),
throwsToolExit(message: 'Missing index.html.')
);
}, overrides: <Type, Generator>{
Platform: () => fakePlatform,
FileSystem: () => fileSystem,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment