Skip to content

Commit

Permalink
flutter start should give better errors when it can't find main
Browse files Browse the repository at this point in the history
Now we suggest using -t to specify the main Dart file.

Fixes #53
  • Loading branch information
abarth committed Nov 9, 2015
1 parent 8a8bd01 commit 6e7f575
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/flutter_tools/lib/src/commands/start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tools/test/start_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down

0 comments on commit 6e7f575

Please sign in to comment.