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

Side by Side Diff: lib/src/global_packages.dart

Issue 1272813003: Support "--checked" in pub run and global run. (Closed) Base URL: https://github.com/dart-lang/pub.git@master
Patch Set: Revise. Created 5 years, 4 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
« no previous file with comments | « lib/src/executable.dart ('k') | test/global/run/runs_script_in_checked_mode_test.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) 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.global_packages; 5 library pub.global_packages;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return new Entrypoint(PathSource.pathFromDescription(id.description), 322 return new Entrypoint(PathSource.pathFromDescription(id.description),
323 cache); 323 cache);
324 } 324 }
325 325
326 /// Runs [package]'s [executable] with [args]. 326 /// Runs [package]'s [executable] with [args].
327 /// 327 ///
328 /// If [executable] is available in its precompiled form, that will be 328 /// If [executable] is available in its precompiled form, that will be
329 /// recompiled if the SDK has been upgraded since it was first compiled and 329 /// recompiled if the SDK has been upgraded since it was first compiled and
330 /// then run. Otherwise, it will be run from source. 330 /// then run. Otherwise, it will be run from source.
331 /// 331 ///
332 /// If [mode] is passed, it's used as the barback mode; it defaults to 332 /// If [checked] is true, the program is run in checked mode. If [mode] is
333 /// passed, it's used as the barback mode; it defaults to
333 /// [BarbackMode.RELEASE]. 334 /// [BarbackMode.RELEASE].
334 /// 335 ///
335 /// Returns the exit code from the executable. 336 /// Returns the exit code from the executable.
336 Future<int> runExecutable(String package, String executable, 337 Future<int> runExecutable(String package, String executable,
337 Iterable<String> args, {BarbackMode mode}) { 338 Iterable<String> args, {bool checked: false, BarbackMode mode}) {
338 if (mode == null) mode = BarbackMode.RELEASE; 339 if (mode == null) mode = BarbackMode.RELEASE;
339 340
340 var binDir = p.join(_directory, package, 'bin'); 341 var binDir = p.join(_directory, package, 'bin');
341 if (mode != BarbackMode.RELEASE || 342 if (mode != BarbackMode.RELEASE ||
342 !fileExists(p.join(binDir, '$executable.dart.snapshot'))) { 343 !fileExists(p.join(binDir, '$executable.dart.snapshot'))) {
343 return find(package).then((entrypoint) { 344 return find(package).then((entrypoint) {
344 return exe.runExecutable(entrypoint, package, executable, args, 345 return exe.runExecutable(entrypoint, package, executable, args,
345 mode: mode, isGlobal: true); 346 isGlobal: true, checked: checked, mode: mode);
346 }); 347 });
347 } 348 }
348 349
349 // Unless the user overrides the verbosity, we want to filter out the 350 // Unless the user overrides the verbosity, we want to filter out the
350 // normal pub output shown while loading the environment. 351 // normal pub output shown while loading the environment.
351 if (log.verbosity == log.Verbosity.NORMAL) { 352 if (log.verbosity == log.Verbosity.NORMAL) {
352 log.verbosity = log.Verbosity.WARNING; 353 log.verbosity = log.Verbosity.WARNING;
353 } 354 }
354 355
355 var snapshotPath = p.join(binDir, '$executable.dart.snapshot'); 356 var snapshotPath = p.join(binDir, '$executable.dart.snapshot');
356 return exe.runSnapshot(snapshotPath, args, recompile: () { 357 return exe.runSnapshot(snapshotPath, args, checked: checked, recompile: () {
357 log.fine("$package:$executable is out of date and needs to be " 358 log.fine("$package:$executable is out of date and needs to be "
358 "recompiled."); 359 "recompiled.");
359 return find(package) 360 return find(package)
360 .then((entrypoint) => entrypoint.loadPackageGraph()) 361 .then((entrypoint) => entrypoint.loadPackageGraph())
361 .then((graph) => _precompileExecutables(graph.entrypoint, package)); 362 .then((graph) => _precompileExecutables(graph.entrypoint, package));
362 }); 363 });
363 } 364 }
364 365
365 /// Gets the path to the lock file for an activated cached package with 366 /// Gets the path to the lock file for an activated cached package with
366 /// [name]. 367 /// [name].
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 779 }
779 780
780 /// Returns the value of the property named [name] in the bin stub script 781 /// Returns the value of the property named [name] in the bin stub script
781 /// [source]. 782 /// [source].
782 String _binStubProperty(String source, String name) { 783 String _binStubProperty(String source, String name) {
783 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); 784 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)");
784 var match = pattern.firstMatch(source); 785 var match = pattern.firstMatch(source);
785 return match == null ? null : match[1]; 786 return match == null ? null : match[1];
786 } 787 }
787 } 788 }
OLDNEW
« no previous file with comments | « lib/src/executable.dart ('k') | test/global/run/runs_script_in_checked_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698