mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
flutter start should give better errors when it can't find main
Now we suggest using -t to specify the main Dart file. Fixes #53
This commit is contained in:
parent
8a8bd0197c
commit
6e7f575950
@ -30,7 +30,7 @@ class StartCommand extends FlutterCommand {
|
||||
defaultsTo: true,
|
||||
help: 'Toggle Dart\'s checked mode.');
|
||||
argParser.addOption('target',
|
||||
defaultsTo: '.',
|
||||
defaultsTo: '',
|
||||
abbr: 't',
|
||||
help: 'Target app path or filename to start.');
|
||||
argParser.addFlag('boot',
|
||||
@ -67,6 +67,14 @@ class StartCommand extends FlutterCommand {
|
||||
String mainPath = target;
|
||||
if (FileSystemEntity.isDirectorySync(target))
|
||||
mainPath = path.join(target, 'lib', 'main.dart');
|
||||
if (!FileSystemEntity.isFileSync(mainPath)) {
|
||||
String message = 'Tried to run ${mainPath}, but that file does not exist.';
|
||||
if (!argResults.wasParsed('target'))
|
||||
message += '\nConsider using the -t option to specify that Dart file to start.';
|
||||
stderr.writeln(message);
|
||||
continue;
|
||||
}
|
||||
|
||||
BuildCommand builder = new BuildCommand();
|
||||
builder.inheritFromParent(this);
|
||||
await builder.buildInTempDir(
|
||||
|
||||
@ -38,7 +38,7 @@ defineTests() {
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
runner.run(['start']).then((int code) => expect(code, equals(0)));
|
||||
runner.run(['start', '-t', 'test/start_test.dart']).then((int code) => expect(code, equals(0)));
|
||||
});
|
||||
|
||||
test('returns 0 when iOS is connected and ready to be started', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user