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

Unified Diff: lib/src/executable.dart

Issue 1277773002: Support resources in "pub run" and "pub global run". (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/command.dart ('k') | lib/src/global_packages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/executable.dart
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index 2c5fd1f14d29a077ce2723d9cda9ef7e4a9ace43..18dd9adc4b5774120e297a970528a0203460bd76 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -9,7 +9,6 @@ import 'dart:io';
import 'package:barback/barback.dart';
import 'package:path/path.dart' as p;
-import 'package:stack_trace/stack_trace.dart';
import 'barback/asset_environment.dart';
import 'entrypoint.dart';
@@ -114,8 +113,6 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
// it knows where to load the packages. If it's a dependency's executable, for
// example, it may not have the right packages directory itself.
if (executableUrl.scheme == 'file' || executableUrl.scheme == '') {
- // TODO(nweiz): use a .packages file once sdk#23369 is fixed.
-
// We use an absolute path here not because the VM insists but because it's
// helpful for the subprocess to be able to spawn Dart with
// Platform.executableArguments and have that work regardless of the working
@@ -210,12 +207,22 @@ Future<Uri> _executableUrl(Entrypoint entrypoint, String package, String path,
///
/// This doesn't do any validation of the snapshot's SDK version.
Future<int> runSnapshot(String path, Iterable<String> args, {recompile(),
- bool checked: false}) async {
- var vmArgs = [path]..addAll(args);
-
+ String packagesFile, bool checked: false}) async {
// TODO(nweiz): pass a flag to silence the "Wrong full snapshot version"
// message when issue 20784 is fixed.
- if (checked) vmArgs.insert(0, "--checked");
+ var vmArgs = [];
+ if (checked) vmArgs.add("--checked");
+
+ if (packagesFile != null) {
+ // We use an absolute path here not because the VM insists but because it's
+ // helpful for the subprocess to be able to spawn Dart with
+ // Platform.executableArguments and have that work regardless of the working
+ // directory.
+ vmArgs.add("--packages=${p.toUri(p.absolute(packagesFile))}");
+ }
+
+ vmArgs.add(path);
+ vmArgs.addAll(args);
// We need to split stdin so that we can send the same input both to the
// first and second process, if we start more than one.
@@ -269,7 +276,10 @@ void _forwardSignals(Process process) {
/// Runs the executable snapshot at [snapshotPath].
Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath,
List<String> args, {bool checked: false}) {
- return runSnapshot(snapshotPath, args, checked: checked, recompile: () {
+ return runSnapshot(snapshotPath, args,
+ packagesFile: entrypoint.packagesFile,
+ checked: checked,
+ recompile: () {
log.fine("Precompiled executable is out of date.");
return entrypoint.precompileExecutables();
});
« no previous file with comments | « lib/src/command.dart ('k') | lib/src/global_packages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698