@@ -14,20 +14,20 @@ import '../utils.dart';
1414
1515/// Handles the `run` pub command.
1616class RunCommand extends PubCommand {
17- String get name => " run" ;
18- String get description => " Run an executable from a package." ;
19- String get invocation => " pub run <executable> [args...]" ;
17+ String get name => ' run' ;
18+ String get description => ' Run an executable from a package.' ;
19+ String get invocation => ' pub run <executable> [args...]' ;
2020 bool get allowTrailingOptions => false ;
2121
2222 RunCommand () {
23- argParser.addFlag ("checked" ,
24- abbr: "c" , help : "Enable runtime type checks and assertions." );
25- argParser.addOption (" mode" , help: " Deprecated option" , hide: true );
23+ argParser.addFlag ('enable-asserts' , help : 'Enable assert statements.' );
24+ argParser. addFlag ( 'checked' , abbr: 'c' , hide : true );
25+ argParser.addOption (' mode' , help: ' Deprecated option' , hide: true );
2626 }
2727
2828 Future run () async {
2929 if (argResults.rest.isEmpty) {
30- usageException (" Must specify an executable to run." );
30+ usageException (' Must specify an executable to run.' );
3131 }
3232
3333 var package = entrypoint.root.name;
@@ -36,31 +36,31 @@ class RunCommand extends PubCommand {
3636
3737 // A command like "foo:bar" runs the "bar" script from the "foo" package.
3838 // If there is no colon prefix, default to the root package.
39- if (executable.contains (":" )) {
40- var components = split1 (executable, ":" );
39+ if (executable.contains (':' )) {
40+ var components = split1 (executable, ':' );
4141 package = components[0 ];
4242 executable = components[1 ];
4343
4444 if (p.split (executable).length > 1 ) {
4545 usageException (
46- " Cannot run an executable in a subdirectory of a dependency." );
46+ ' Cannot run an executable in a subdirectory of a dependency.' );
4747 }
4848 } else if (onlyIdentifierRegExp.hasMatch (executable)) {
4949 // "pub run foo" means the same thing as "pub run foo:foo" as long as
5050 // "foo" is a valid Dart identifier (and thus package name).
5151 package = executable;
5252 }
5353
54- if (argResults.wasParsed (" mode" )) {
55- log.warning (" The --mode flag is deprecated and has no effect." );
54+ if (argResults.wasParsed (' mode' )) {
55+ log.warning (' The --mode flag is deprecated and has no effect.' );
5656 }
5757
5858 // The user may pass in an executable without an extension, but the file
5959 // to actually execute will always have one.
60- if (p.extension (executable) != " .dart" ) executable += " .dart" ;
60+ if (p.extension (executable) != ' .dart' ) executable += ' .dart' ;
6161
6262 var snapshotPath = p.join (
63- entrypoint.cachePath, " bin" , package, " $executable .snapshot.dart2" );
63+ entrypoint.cachePath, ' bin' , package, ' $executable .snapshot.dart2' );
6464
6565 // Don't ever compile snapshots for mutable packages, since their code may
6666 // change later on.
@@ -69,7 +69,7 @@ class RunCommand extends PubCommand {
6969 ! entrypoint.packageGraph.isPackageMutable (package));
7070
7171 var exitCode = await runExecutable (entrypoint, package, executable, args,
72- checked: argResults['checked' ],
72+ checked: argResults['enable-asserts' ] || argResults[ ' checked' ],
7373 snapshotPath: useSnapshot ? snapshotPath : null ,
7474 recompile: entrypoint.precompileExecutables);
7575 await flushThenExit (exitCode);
0 commit comments