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