Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:path/path.dart' as p; | 8 import 'package:path/path.dart' as p; |
| 9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:pub_semver/pub_semver.dart'; | 10 import 'package:pub_semver/pub_semver.dart'; |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 if (result.exitCode == 0) return; | 763 if (result.exitCode == 0) return; |
| 764 | 764 |
| 765 log.warning( | 765 log.warning( |
| 766 "${log.yellow('Warning:')} Pub installs executables into " | 766 "${log.yellow('Warning:')} Pub installs executables into " |
| 767 "${log.bold(_binStubDir)}, which is not on your path.\n" | 767 "${log.bold(_binStubDir)}, which is not on your path.\n" |
| 768 "You can fix that by adding that directory to your system's " | 768 "You can fix that by adding that directory to your system's " |
| 769 '"Path" environment variable.\n' | 769 '"Path" environment variable.\n' |
| 770 'A web search for "configure windows path" will show you how.'); | 770 'A web search for "configure windows path" will show you how.'); |
| 771 } else { | 771 } else { |
| 772 // See if the shell can find one of the binstubs. | 772 // See if the shell can find one of the binstubs. |
| 773 var result = runProcessSync("which", [installed]); | 773 // |
| 774 // The "command" builtin is more reliable than the "which" executable. See | |
| 775 // http://unix.stackexchange.com/questions/85249/why-not-use-which-what-to -use-then | |
| 776 var result = runProcessSync("sh", ["-c", 'command -v "\$installed"'], | |
|
kevmoo
2016/07/14 21:22:13
...or just add 'runInShell: true' ?
nweiz
2016/07/14 22:06:56
Haha good idea!
| |
| 777 environment: {"installed": installed}); | |
| 774 if (result.exitCode == 0) return; | 778 if (result.exitCode == 0) return; |
| 775 | 779 |
| 776 var binDir = _binStubDir; | 780 var binDir = _binStubDir; |
| 777 if (binDir.startsWith(Platform.environment['HOME'])) { | 781 if (binDir.startsWith(Platform.environment['HOME'])) { |
| 778 binDir = p.join("~", p.relative(binDir, | 782 binDir = p.join("~", p.relative(binDir, |
| 779 from: Platform.environment['HOME'])); | 783 from: Platform.environment['HOME'])); |
| 780 } | 784 } |
| 781 | 785 |
| 782 log.warning( | 786 log.warning( |
| 783 "${log.yellow('Warning:')} Pub installs executables into " | 787 "${log.yellow('Warning:')} Pub installs executables into " |
| 784 "${log.bold(binDir)}, which is not on your path.\n" | 788 "${log.bold(binDir)}, which is not on your path.\n" |
| 785 "You can fix that by adding this to your shell's config file " | 789 "You can fix that by adding this to your shell's config file " |
| 786 "(.bashrc, .bash_profile, etc.):\n" | 790 "(.bashrc, .bash_profile, etc.):\n" |
| 787 "\n" | 791 "\n" |
| 788 " ${log.bold('export PATH="\$PATH":"$binDir"')}\n" | 792 " ${log.bold('export PATH="\$PATH":"$binDir"')}\n" |
| 789 "\n"); | 793 "\n"); |
| 790 } | 794 } |
| 791 } | 795 } |
| 792 | 796 |
| 793 /// Returns the value of the property named [name] in the bin stub script | 797 /// Returns the value of the property named [name] in the bin stub script |
| 794 /// [source]. | 798 /// [source]. |
| 795 String _binStubProperty(String source, String name) { | 799 String _binStubProperty(String source, String name) { |
| 796 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); | 800 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); |
| 797 var match = pattern.firstMatch(source); | 801 var match = pattern.firstMatch(source); |
| 798 return match == null ? null : match[1]; | 802 return match == null ? null : match[1]; |
| 799 } | 803 } |
| 800 } | 804 } |
| OLD | NEW |