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

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

Issue 12042053: Get rid of unneeded Future.immediate() calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
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 /// The main entrypoint for the pub command line application. 5 /// The main entrypoint for the pub command line application.
6 library pub; 6 library pub;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import '../../pkg/args/lib/args.dart'; 9 import '../../pkg/args/lib/args.dart';
10 import '../../pkg/path/lib/path.dart' as path; 10 import '../../pkg/path/lib/path.dart' as path;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // TODO(rnystrom): Will eventually need better logic to walk up 239 // TODO(rnystrom): Will eventually need better logic to walk up
240 // subdirectories until we hit one that looks package-like. For now, just 240 // subdirectories until we hit one that looks package-like. For now, just
241 // assume the cwd is it. 241 // assume the cwd is it.
242 future = Entrypoint.load(path.current, cache); 242 future = Entrypoint.load(path.current, cache);
243 } 243 }
244 244
245 future = future.then((entrypoint) { 245 future = future.then((entrypoint) {
246 this.entrypoint = entrypoint; 246 this.entrypoint = entrypoint;
247 try { 247 try {
248 var commandFuture = onRun(); 248 var commandFuture = onRun();
249 if (commandFuture == null) return new Future.immediate(true); 249 if (commandFuture == null) return true;
250 250
251 return commandFuture; 251 return commandFuture;
252 } catch (error, trace) { 252 } catch (error, trace) {
253 handleError(error, trace); 253 handleError(error, trace);
254 return new Future.immediate(null);
255 } 254 }
256 }); 255 });
257 256
258
259 future 257 future
260 .then((_) => cache_.deleteTempDir()) 258 .then((_) => cache_.deleteTempDir())
261 .catchError((asyncError) { 259 .catchError((asyncError) {
262 var e = asyncError.error; 260 var e = asyncError.error;
263 if (e is PubspecNotFoundException && e.name == null) { 261 if (e is PubspecNotFoundException && e.name == null) {
264 e = 'Could not find a file named "pubspec.yaml" in the directory ' 262 e = 'Could not find a file named "pubspec.yaml" in the directory '
265 '${path.current}.'; 263 '${path.current}.';
266 } else if (e is PubspecHasNoNameException && e.name == null) { 264 } else if (e is PubspecHasNoNameException && e.name == null) {
267 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' 265 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: '
268 '${basename(path.current)}").'; 266 '${basename(path.current)}").';
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (exception is HttpException || exception is HttpParserException || 300 if (exception is HttpException || exception is HttpParserException ||
303 exception is SocketIOException || exception is PubHttpException) { 301 exception is SocketIOException || exception is PubHttpException) {
304 return exit_codes.UNAVAILABLE; 302 return exit_codes.UNAVAILABLE;
305 } else if (exception is FormatException) { 303 } else if (exception is FormatException) {
306 return exit_codes.DATA; 304 return exit_codes.DATA;
307 } else { 305 } else {
308 return 1; 306 return 1;
309 } 307 }
310 } 308 }
311 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698