Support running pub when it's not on the environment path (#26)
diff --git a/appveyor.yml b/appveyor.yml
index e0baced..9aea605 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -8,15 +8,14 @@
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
- cmd: echo "Unzipping dart-sdk..."
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
- - set PATH=%PATH%;C:\tools\dart-sdk\bin
- set PATH=%PATH%;%APPDATA%\Pub\Cache\bin
- cd webdev
- - pub get && exit 0
+ - C:\tools\dart-sdk\bin\pub.bat get && exit 0
build: off
test_script:
- - pub run test -j 1
+ - C:\tools\dart-sdk\bin\pub.bat run test -j 1
cache:
- C:\Users\appveyor\AppData\Roaming\Pub\Cache
diff --git a/webdev/CHANGELOG.md b/webdev/CHANGELOG.md
index d048f9b..c7dab95 100644
--- a/webdev/CHANGELOG.md
+++ b/webdev/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.3+1
+
+- Support running `pub` when it's not in the environment path.
+
## 0.1.3
- Now runs on Windows.
diff --git a/webdev/lib/src/pubspec.dart b/webdev/lib/src/pubspec.dart
index 1705b10..8055731 100644
--- a/webdev/lib/src/pubspec.dart
+++ b/webdev/lib/src/pubspec.dart
@@ -38,7 +38,7 @@
}
Future _runPubDeps() async {
- var result = Process.runSync('pub', ['deps'], runInShell: true);
+ var result = Process.runSync(pubPath, ['deps']);
if (result.exitCode == 65 || result.exitCode == 66) {
throw new PackageException._(
@@ -47,7 +47,7 @@
if (result.exitCode != 0) {
throw new ProcessException(
- 'pub',
+ pubPath,
['deps'],
'***OUT***\n${result.stdout}\n***ERR***\n${result.stderr}\n***',
exitCode);
diff --git a/webdev/lib/src/util.dart b/webdev/lib/src/util.dart
index 99be8d4..f0d13f0 100644
--- a/webdev/lib/src/util.dart
+++ b/webdev/lib/src/util.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:io';
+
+import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
final supportedBuildRunnerVersionRange = new VersionRange(
@@ -9,3 +12,17 @@
includeMin: true,
max: new Version(0, 9, 0),
includeMax: false);
+
+/// The path to the root directory of the SDK.
+final String _sdkDir = (() {
+ // The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
+ // "/path/to/sdk".
+ var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable));
+ assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
+ return aboveExecutable;
+})();
+
+final String dartPath =
+ p.join(_sdkDir, 'bin', Platform.isWindows ? 'dart.exe' : 'dart');
+final String pubPath =
+ p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub');
diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml
index fcec1f3..ad0e754 100644
--- a/webdev/pubspec.yaml
+++ b/webdev/pubspec.yaml
@@ -1,5 +1,5 @@
name: webdev
-version: 0.1.3
+version: 0.1.3+1
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/webdev
description: >-
diff --git a/webdev/test/integration_test.dart b/webdev/test/integration_test.dart
index ec92217..aeafed8 100644
--- a/webdev/test/integration_test.dart
+++ b/webdev/test/integration_test.dart
@@ -9,25 +9,14 @@
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;
import 'package:test_process/test_process.dart';
+import 'package:webdev/src/util.dart';
final _webdevBin = p.absolute(p.join('bin', 'webdev.dart'));
-/// The path to the root directory of the SDK.
-final String _sdkDir = (() {
- // The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
- // "/path/to/sdk".
- var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable));
- assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
- return aboveExecutable;
-})();
-
-final String _dartPath = p.join(_sdkDir, 'bin', 'dart');
-final String _pubPath = p.join(_sdkDir, 'bin', 'pub');
-
Future<TestProcess> _runWebDev(List<String> args, {String workingDirectory}) {
var fullArgs = [_webdevBin]..addAll(args);
- return TestProcess.start(_dartPath, fullArgs,
+ return TestProcess.start(dartPath, fullArgs,
workingDirectory: workingDirectory);
}
@@ -218,10 +207,8 @@
test('should succeed with valid configuration', () async {
var exampleDirectory = p.absolute(p.join(p.current, '..', 'example'));
- var process = await TestProcess.start(_pubPath, ['get'],
- workingDirectory: exampleDirectory,
- environment: _getPubEnvironment(),
- runInShell: true);
+ var process = await TestProcess.start(pubPath, ['get'],
+ workingDirectory: exampleDirectory, environment: _getPubEnvironment());
await process.shouldExit(0);