Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: utils/pub/command_uploader.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/release/version.dart ('k') | utils/pub/entrypoint.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 command_uploader; 5 library command_uploader;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (!['add', 'remove'].contains(command)) { 52 if (!['add', 'remove'].contains(command)) {
53 log.error('Unknown uploader command "$command".'); 53 log.error('Unknown uploader command "$command".');
54 this.printUsage(); 54 this.printUsage();
55 exit(exit_codes.USAGE); 55 exit(exit_codes.USAGE);
56 } else if (commandOptions.rest.isEmpty) { 56 } else if (commandOptions.rest.isEmpty) {
57 log.error('No uploader given for "pub uploader $command".'); 57 log.error('No uploader given for "pub uploader $command".');
58 this.printUsage(); 58 this.printUsage();
59 exit(exit_codes.USAGE); 59 exit(exit_codes.USAGE);
60 } 60 }
61 61
62 return new Future.of(() { 62 return new Future.sync(() {
63 var package = commandOptions['package']; 63 var package = commandOptions['package'];
64 if (package != null) return package; 64 if (package != null) return package;
65 return new Entrypoint(path.current, cache).root.name; 65 return new Entrypoint(path.current, cache).root.name;
66 }).then((package) { 66 }).then((package) {
67 var uploader = commandOptions.rest[0]; 67 var uploader = commandOptions.rest[0];
68 return oauth2.withClient(cache, (client) { 68 return oauth2.withClient(cache, (client) {
69 if (command == 'add') { 69 if (command == 'add') {
70 var url = server.resolve("/packages/${encodeUriComponent(package)}" 70 var url = server.resolve("/packages/${encodeUriComponent(package)}"
71 "/uploaders.json"); 71 "/uploaders.json");
72 return client.post(url, fields: {"email": uploader}); 72 return client.post(url, fields: {"email": uploader});
73 } else { // command == 'remove' 73 } else { // command == 'remove'
74 var url = server.resolve("/packages/${encodeUriComponent(package)}" 74 var url = server.resolve("/packages/${encodeUriComponent(package)}"
75 "/uploaders/${encodeUriComponent(uploader)}.json"); 75 "/uploaders/${encodeUriComponent(uploader)}.json");
76 return client.delete(url); 76 return client.delete(url);
77 } 77 }
78 }); 78 });
79 }).then(handleJsonSuccess) 79 }).then(handleJsonSuccess)
80 .catchError((error) => handleJsonError(error.response), 80 .catchError((error) => handleJsonError(error.response),
81 test: (e) => e is PubHttpException); 81 test: (e) => e is PubHttpException);
82 } 82 }
83 } 83 }
OLDNEW
« no previous file with comments | « tools/release/version.dart ('k') | utils/pub/entrypoint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698