From 208c11bf16f5ac6196064abfc3236fc27041d1ec Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 3 Apr 2018 09:02:51 -0700 Subject: [PATCH 1/2] Support running pub when it's not on the environment path --- webdev/CHANGELOG.md | 4 ++++ webdev/lib/src/pubspec.dart | 2 +- webdev/lib/src/util.dart | 16 ++++++++++++++++ webdev/pubspec.yaml | 2 +- webdev/test/integration_test.dart | 17 +++-------------- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/webdev/CHANGELOG.md b/webdev/CHANGELOG.md index d048f9b39..c7dab95c9 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 1705b100e..ad83ae820 100644 --- a/webdev/lib/src/pubspec.dart +++ b/webdev/lib/src/pubspec.dart @@ -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); diff --git a/webdev/lib/src/util.dart b/webdev/lib/src/util.dart index 99be8d4db..2b5543b35 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,16 @@ final supportedBuildRunnerVersionRange = new VersionRange( 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', 'dart'); +final String pubPath = + p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub'); diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index fcec1f37f..ad0e754ce 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 homepage: https://github.com/dart-lang/webdev description: >- diff --git a/webdev/test/integration_test.dart b/webdev/test/integration_test.dart index ec9221711..4760c296d 100644 --- a/webdev/test/integration_test.dart +++ b/webdev/test/integration_test.dart @@ -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 _runWebDev(List args, {String workingDirectory}) { var fullArgs = [_webdevBin]..addAll(args); - return TestProcess.start(_dartPath, fullArgs, + return TestProcess.start(dartPath, fullArgs, workingDirectory: workingDirectory); } @@ -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); From ac0b33f457e3c1b510bd82c5b41d718a81dac664 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 3 Apr 2018 09:34:05 -0700 Subject: [PATCH 2/2] other thing... --- appveyor.yml | 5 ++--- webdev/lib/src/pubspec.dart | 2 +- webdev/lib/src/util.dart | 3 ++- webdev/test/integration_test.dart | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e0baced33..9aea60506 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,15 +8,14 @@ install: - 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/lib/src/pubspec.dart b/webdev/lib/src/pubspec.dart index ad83ae820..8055731e2 100644 --- a/webdev/lib/src/pubspec.dart +++ b/webdev/lib/src/pubspec.dart @@ -38,7 +38,7 @@ class PackageExceptionDetails { } 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._( diff --git a/webdev/lib/src/util.dart b/webdev/lib/src/util.dart index 2b5543b35..f0d13f0e1 100644 --- a/webdev/lib/src/util.dart +++ b/webdev/lib/src/util.dart @@ -22,6 +22,7 @@ final String _sdkDir = (() { return aboveExecutable; })(); -final String dartPath = p.join(_sdkDir, 'bin', 'dart'); +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/test/integration_test.dart b/webdev/test/integration_test.dart index 4760c296d..aeafed822 100644 --- a/webdev/test/integration_test.dart +++ b/webdev/test/integration_test.dart @@ -208,9 +208,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'], - workingDirectory: exampleDirectory, - environment: _getPubEnvironment(), - runInShell: true); + workingDirectory: exampleDirectory, environment: _getPubEnvironment()); await process.shouldExit(0);