Chromium Code Reviews| Index: utils/pub/command_lish.dart |
| =================================================================== |
| --- utils/pub/command_lish.dart (revision 18320) |
| +++ utils/pub/command_lish.dart (working copy) |
| @@ -32,6 +32,9 @@ |
| var parser = new ArgParser(); |
| // TODO(nweiz): Use HostedSource.defaultUrl as the default value once we use |
| // dart:io for HTTPS requests. |
| + parser.addFlag('dry-run', abbr: 'n', negatable: false, |
| + help: "Preview publishing the package\n" |
| + "Validate but do not publish the package"); |
|
Bob Nystrom
2013/02/12 01:00:41
You can remove the "Preview..." line.
keertip
2013/02/12 05:20:20
Done.
|
| parser.addOption('server', defaultsTo: 'https://pub.dartlang.org', |
| help: 'The package server to which to upload this package'); |
| return parser; |
| @@ -100,9 +103,11 @@ |
| // Validate the package. |
| return _validate(packageBytesFuture.then((bytes) => bytes.length)) |
| - .then((_) => packageBytesFuture).then(_publish); |
| + .then((validate) { |
|
Bob Nystrom
2013/02/12 01:00:41
"validate" -> "isValid"
keertip
2013/02/12 05:20:20
Done.
|
| + if (validate) return packageBytesFuture.then(_publish); |
| + }); |
|
Bob Nystrom
2013/02/12 01:00:41
The styling of this is a bit strange. How about:
keertip
2013/02/12 05:20:20
Done.
|
| } |
| - |
| + |
| /// The basenames of files that are automatically excluded from archives. |
| final _BLACKLISTED_FILES = const ['pubspec.lock']; |
| @@ -146,7 +151,7 @@ |
| } |
| /// Validates the package. Throws an exception if it's invalid. |
| - Future _validate(Future<int> packageSize) { |
| + Future<bool> _validate(Future<int> packageSize) { |
| return Validator.runAll(entrypoint, packageSize).then((pair) { |
| var errors = pair.first; |
| var warnings = pair.last; |
| @@ -158,6 +163,12 @@ |
| "http://pub.dartlang.org/doc/pub-lish.html.\n"; |
|
Bob Nystrom
2013/02/12 01:00:41
Instead of throwing, just use log.error() to print
keertip
2013/02/12 05:20:20
With this change, publish will return with exitcod
Bob Nystrom
2013/02/12 19:00:57
Hmm. Good point. I think I'm OK with that for now
|
| } |
| + if (commandOptions['dry-run']){ |
| + var s = warnings.length == 1 ? '' : 's'; |
| + log.warning("Package has ${warnings.length} warning$s."); |
| + return new Future.immediate(false); |
|
Bob Nystrom
2013/02/12 01:00:41
You don't need Future here, just "return false;"
keertip
2013/02/12 05:20:20
Done.
|
| + } |
| + |
| var message = 'Looks great! Are you ready to upload your package'; |
| if (!warnings.isEmpty) { |
| @@ -167,6 +178,7 @@ |
| return confirm(message).then((confirmed) { |
| if (!confirmed) throw "Package upload canceled."; |
|
Bob Nystrom
2013/02/12 01:00:41
Instead of throwing here, do log.message() then re
keertip
2013/02/12 05:20:20
Done.
|
| + return new Future.immediate(true); |
|
Bob Nystrom
2013/02/12 01:00:41
Just "return true".
keertip
2013/02/12 05:20:20
Done.
|
| }); |
| }); |
| } |