Skip to content

Commit 208c11b

Browse files
committed
Support running pub when it's not on the environment path
1 parent bb44773 commit 208c11b

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
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 = p.join(_sdkDir, 'bin', 'dart');
26+
final String pubPath =
27+
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: 3 additions & 14 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,7 +207,7 @@ 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'],
210+
var process = await TestProcess.start(pubPath, ['get'],
222211
workingDirectory: exampleDirectory,
223212
environment: _getPubEnvironment(),
224213
runInShell: true);

0 commit comments

Comments
 (0)