Skip to content

Commit ccf432b

Browse files
authored
Support running pub when it's not on the environment path (#26)
1 parent bb44773 commit ccf432b

File tree

6 files changed

+30
-23
lines changed

6 files changed

+30
-23
lines changed

appveyor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ install:
88
- ps: wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-windows-x64-release.zip -OutFile dart-sdk.zip
99
- cmd: echo "Unzipping dart-sdk..."
1010
- cmd: 7z x dart-sdk.zip -o"C:\tools" -y > nul
11-
- set PATH=%PATH%;C:\tools\dart-sdk\bin
1211
- set PATH=%PATH%;%APPDATA%\Pub\Cache\bin
1312
- cd webdev
14-
- pub get && exit 0
13+
- C:\tools\dart-sdk\bin\pub.bat get && exit 0
1514

1615
build: off
1716

1817
test_script:
19-
- pub run test -j 1
18+
- C:\tools\dart-sdk\bin\pub.bat run test -j 1
2019

2120
cache:
2221
- C:\Users\appveyor\AppData\Roaming\Pub\Cache

webdev/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.3+1
2+
3+
- Support running `pub` when it's not in the environment path.
4+
15
## 0.1.3
26

37
- Now runs on Windows.

webdev/lib/src/pubspec.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PackageExceptionDetails {
3838
}
3939

4040
Future _runPubDeps() async {
41-
var result = Process.runSync('pub', ['deps'], runInShell: true);
41+
var result = Process.runSync(pubPath, ['deps']);
4242

4343
if (result.exitCode == 65 || result.exitCode == 66) {
4444
throw new PackageException._(
@@ -47,7 +47,7 @@ Future _runPubDeps() async {
4747

4848
if (result.exitCode != 0) {
4949
throw new ProcessException(
50-
'pub',
50+
pubPath,
5151
['deps'],
5252
'***OUT***\n${result.stdout}\n***ERR***\n${result.stderr}\n***',
5353
exitCode);

webdev/lib/src/util.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
6+
7+
import 'package:path/path.dart' as p;
58
import 'package:pub_semver/pub_semver.dart';
69

710
final supportedBuildRunnerVersionRange = new VersionRange(
811
min: new Version(0, 8, 0),
912
includeMin: true,
1013
max: new Version(0, 9, 0),
1114
includeMax: false);
15+
16+
/// The path to the root directory of the SDK.
17+
final String _sdkDir = (() {
18+
// The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
19+
// "/path/to/sdk".
20+
var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable));
21+
assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
22+
return aboveExecutable;
23+
})();
24+
25+
final String dartPath =
26+
p.join(_sdkDir, 'bin', Platform.isWindows ? 'dart.exe' : 'dart');
27+
final String pubPath =
28+
p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub');

webdev/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: webdev
2-
version: 0.1.3
2+
version: 0.1.3+1
33
author: Dart Team <[email protected]>
44
homepage: https://github.com/dart-lang/webdev
55
description: >-

webdev/test/integration_test.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@ import 'package:path/path.dart' as p;
99
import 'package:test/test.dart';
1010
import 'package:test_descriptor/test_descriptor.dart' as d;
1111
import 'package:test_process/test_process.dart';
12+
import 'package:webdev/src/util.dart';
1213

1314
final _webdevBin = p.absolute(p.join('bin', 'webdev.dart'));
1415

15-
/// The path to the root directory of the SDK.
16-
final String _sdkDir = (() {
17-
// The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is
18-
// "/path/to/sdk".
19-
var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable));
20-
assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version')));
21-
return aboveExecutable;
22-
})();
23-
24-
final String _dartPath = p.join(_sdkDir, 'bin', 'dart');
25-
final String _pubPath = p.join(_sdkDir, 'bin', 'pub');
26-
2716
Future<TestProcess> _runWebDev(List<String> args, {String workingDirectory}) {
2817
var fullArgs = [_webdevBin]..addAll(args);
2918

30-
return TestProcess.start(_dartPath, fullArgs,
19+
return TestProcess.start(dartPath, fullArgs,
3120
workingDirectory: workingDirectory);
3221
}
3322

@@ -218,10 +207,8 @@ dependencies:
218207

219208
test('should succeed with valid configuration', () async {
220209
var exampleDirectory = p.absolute(p.join(p.current, '..', 'example'));
221-
var process = await TestProcess.start(_pubPath, ['get'],
222-
workingDirectory: exampleDirectory,
223-
environment: _getPubEnvironment(),
224-
runInShell: true);
210+
var process = await TestProcess.start(pubPath, ['get'],
211+
workingDirectory: exampleDirectory, environment: _getPubEnvironment());
225212

226213
await process.shouldExit(0);
227214

0 commit comments

Comments
 (0)