Index: utils/tests/pub/test_pub.dart |
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart |
index 80137a0d5580a7fc73f3f8ba023ce963ca3a4522..1f5244d85849337daffed9f811441964f58b9502 100644 |
--- a/utils/tests/pub/test_pub.dart |
+++ b/utils/tests/pub/test_pub.dart |
@@ -596,10 +596,10 @@ void schedulePub({List<String> args, Pattern output, Pattern error, |
}); |
} |
-/** |
- * A shorthand for [schedulePub] and [run] when no validation needs to be done |
- * after Pub has been run. |
- */ |
+/// A shorthand for [schedulePub] and [run] when no validation needs to be done |
+/// after Pub has been run. |
+/// |
+/// Any futures in [args] will be resolved before the process is started. |
void runPub({List<String> args, Pattern output, Pattern error, |
Bob Nystrom
2012/12/17 18:41:58
List<String> -> List, here and elsewhere.
if it c
nweiz
2012/12/17 21:18:48
Done.
|
int exitCode: 0}) { |
schedulePub(args: args, output: output, error: error, exitCode: exitCode); |
@@ -608,25 +608,25 @@ void runPub({List<String> args, Pattern output, Pattern error, |
/// Starts a Pub process and returns a [ScheduledProcess] that supports |
/// interaction with that process. |
-ScheduledProcess startPub({List<String> args}) { |
+/// |
+/// Any futures in [args] will be resolved before the process is started. |
+ScheduledProcess startPub({List<String> args, Future<Uri> tokenEndpoint}) { |
var process = _scheduleValue((sandboxDir) => |
- _doPub(startProcess, sandboxDir, args)); |
+ _doPub(startProcess, sandboxDir, args, tokenEndpoint)); |
return new ScheduledProcess("pub", process); |
} |
/// Like [startPub], but runs `pub lish` in particular with [server] used both |
/// as the OAuth2 server (with "/token" as the token endpoint) and as the |
/// package server. |
+/// |
+/// Any futures in [args] will be resolved before the process is started. |
ScheduledProcess startPubLish(ScheduledServer server, {List<String> args}) { |
- var process = _scheduleValue((sandboxDir) { |
- return server.url.chain((url) { |
- var tokenEndpoint = url.resolve('/token'); |
- if (args == null) args = []; |
- args = flatten(['lish', '--server', url.toString(), args]); |
- return _doPub(startProcess, sandboxDir, args, tokenEndpoint); |
- }); |
- }); |
- return new ScheduledProcess("pub lish", process); |
+ var tokenEndpoint = server.url.transform((url) => |
+ url.resolve('/token').toString()); |
+ if (args == null) args = []; |
+ args = flatten(['lish', '--server', tokenEndpoint, args]); |
+ return startPub(args: args, tokenEndpoint: tokenEndpoint); |
} |
/// Handles the beginning confirmation process for uploading a packages. |
@@ -649,10 +649,17 @@ void confirmPublish(ScheduledProcess pub) { |
/// Calls [fn] with appropriately modified arguments to run a pub process. [fn] |
/// should have the same signature as [startProcess], except that the returned |
/// [Future] may have a type other than [Process]. |
-Future _doPub(Function fn, sandboxDir, List<String> args, Uri tokenEndpoint) { |
+Future _doPub(Function fn, sandboxDir, List<String> args, |
+ Future<Uri> tokenEndpoint) { |
String pathInSandbox(path) => join(getFullPath(sandboxDir), path); |
- return ensureDir(pathInSandbox(appPath)).chain((_) { |
+ return Futures.wait([ |
+ ensureDir(pathInSandbox(appPath)), |
+ _awaitObject(args), |
+ tokenEndpoint == null ? new Future.immediate(null) : tokenEndpoint |
+ ]).chain((results) { |
+ var args = results[1]; |
+ var tokenEndpoint = results[2]; |
// Find a Dart executable we can use to spawn. Use the same one that was |
// used to run this script itself. |
var dartBin = new Options().executable; |