Skip to content

Commit 19538ee

Browse files
committed
Merge pull request dart-archive/cli_util#4 from dart-lang/null_link_fix
Null link fix
2 parents 844f397 + 74cfeca commit 19538ee

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

pkgs/cli_util/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.0.1+1
4+
5+
- Fix for when the dart executable can't be found by `which`.
6+
37
## 0.0.1
48

59
- Initial version

pkgs/cli_util/lib/cli_util.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ Directory getSdkDir([List<String> cliArgs]) {
3838
// Try and locate the VM using 'which'.
3939
String executable = whichSync('dart', orElse: () => null);
4040

41-
// In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links.
42-
Link link = new Link(executable);
43-
if (link.existsSync()) {
44-
executable = link.resolveSymbolicLinksSync();
45-
}
41+
if (executable != null) {
42+
// In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links.
43+
Link link = new Link(executable);
44+
if (link.existsSync()) {
45+
executable = link.resolveSymbolicLinksSync();
46+
}
4647

47-
File dartVm = new File(executable);
48-
Directory dir = dartVm.parent.parent;
49-
if (_isSdkDir(dir)) return dir;
48+
File dartVm = new File(executable);
49+
Directory dir = dartVm.parent.parent;
50+
if (_isSdkDir(dir)) return dir;
51+
}
5052

5153
return null;
5254
}

pkgs/cli_util/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cli_util
2-
version: 0.0.1
2+
version: 0.0.1+1
33
author: Dart Team <misc@dartlang.org>
44
description: A library to help in building Dart command-line apps.
55
homepage: https://github.com/dart-lang/cli_util

0 commit comments

Comments
 (0)