Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running pub when it's not on the environment path #26

Merged
merged 2 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion webdev/lib/src/pubspec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Future _runPubDeps() async {

if (result.exitCode != 0) {
throw new ProcessException(
'pub',
pubPath,
['deps'],
'***OUT***\n${result.stdout}\n***ERR***\n${result.stderr}\n***',
exitCode);
Expand Down
16 changes: 16 additions & 0 deletions webdev/lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@
// 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(
min: new Version(0, 8, 0),
includeMin: true,
max: new Version(0, 9, 0),
includeMax: false);

/// The path to the root directory of the SDK.
final String _sdkDir = (() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be doing this instead of using cli_util?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not worth the dependency for a one-line method.

// 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', Platform.isWindows ? 'pub.bat' : 'pub');
2 changes: 1 addition & 1 deletion webdev/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down
17 changes: 3 additions & 14 deletions webdev/test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,14 @@ import 'package:path/path.dart' as p;
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);
}

Expand Down Expand Up @@ -218,7 +207,7 @@ dependencies:

test('should succeed with valid configuration', () async {
var exampleDirectory = p.absolute(p.join(p.current, '..', 'example'));
var process = await TestProcess.start(_pubPath, ['get'],
var process = await TestProcess.start(pubPath, ['get'],
workingDirectory: exampleDirectory,
environment: _getPubEnvironment(),
runInShell: true);
Expand Down