OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library pub.command.run; | 5 library pub.command.run; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 if (p.split(executable).length > 1) { | 49 if (p.split(executable).length > 1) { |
50 // TODO(nweiz): Use adjacent strings when the new async/await compiler | 50 // TODO(nweiz): Use adjacent strings when the new async/await compiler |
51 // lands. | 51 // lands. |
52 usageException("Cannot run an executable in a subdirectory of a " + | 52 usageException("Cannot run an executable in a subdirectory of a " + |
53 "dependency."); | 53 "dependency."); |
54 } | 54 } |
55 } else if (onlyIdentifierRegExp.hasMatch(executable)) { | 55 } else if (onlyIdentifierRegExp.hasMatch(executable)) { |
56 // "pub run foo" means the same thing as "pub run foo:foo" as long as | 56 // "pub run foo" means the same thing as "pub run foo:foo" as long as |
57 // "foo" is a valid Dart identifier (and thus package name). | 57 // "foo" is a valid Dart identifier (and thus package name). |
58 | 58 package = executable; |
59 // TODO(nweiz): Remove this after Dart 1.10 ships. | |
60 var localPath = p.join("bin", "$executable.dart"); | |
61 if (fileExists(localPath) && executable != entrypoint.root.name) { | |
62 log.warning( | |
63 'In future releases, "pub run $executable" will mean the same ' | |
64 'thing as "pub run $executable:$executable".\n' | |
65 'Run "pub run ${p.join("bin", executable)}" explicitly to run the ' | |
66 'local executable.'); | |
67 } else { | |
68 package = executable; | |
69 } | |
70 } | 59 } |
71 | 60 |
72 var mode; | 61 var mode; |
73 if (argResults['mode'] != null) { | 62 if (argResults['mode'] != null) { |
74 mode = new BarbackMode(argResults['mode']); | 63 mode = new BarbackMode(argResults['mode']); |
75 } else if (package == entrypoint.root.name) { | 64 } else if (package == entrypoint.root.name) { |
76 mode = BarbackMode.DEBUG; | 65 mode = BarbackMode.DEBUG; |
77 } else { | 66 } else { |
78 mode = BarbackMode.RELEASE; | 67 mode = BarbackMode.RELEASE; |
79 } | 68 } |
80 | 69 |
81 var exitCode = await runExecutable(entrypoint, package, executable, args, | 70 var exitCode = await runExecutable(entrypoint, package, executable, args, |
82 mode: mode); | 71 mode: mode); |
83 await flushThenExit(exitCode); | 72 await flushThenExit(exitCode); |
84 } | 73 } |
85 } | 74 } |
OLD | NEW |