From 12f7a765a3567c03cc58f9d013815423f303678d Mon Sep 17 00:00:00 2001 From: pquitslund Date: Tue, 10 Feb 2015 10:21:55 -0800 Subject: [PATCH 1/4] Check for null return from which(). --- lib/cli_util.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cli_util.dart b/lib/cli_util.dart index a997c43..ac767b2 100644 --- a/lib/cli_util.dart +++ b/lib/cli_util.dart @@ -37,6 +37,7 @@ Directory getSdkDir([List cliArgs]) { // Try and locate the VM using 'which'. String executable = whichSync('dart', orElse: () => null); + if (executable == null) return null; // In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links. Link link = new Link(executable); From 02ab4b3a433c9d01b130eb71f5c1ad246655c927 Mon Sep 17 00:00:00 2001 From: pquitslund Date: Tue, 10 Feb 2015 10:31:40 -0800 Subject: [PATCH 2/4] Version rev. --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a2d63c..ec557a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.0.1+1 + +- Fix for when the dart executable can't be found by ``which``. + ## 0.0.1 - Initial version diff --git a/pubspec.yaml b/pubspec.yaml index 0beb6cc..80f21e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: cli_util -version: 0.0.1 +version: 0.0.1+1 author: Dart Team description: A library to help in building Dart command-line apps. homepage: https://github.com/dart-lang/cli_util From 50c16dcc22458c6ff1b3aa52cae5c6502b213c96 Mon Sep 17 00:00:00 2001 From: pquitslund Date: Tue, 10 Feb 2015 10:38:30 -0800 Subject: [PATCH 3/4] Fixed MD. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec557a8..7271432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 0.0.1+1 -- Fix for when the dart executable can't be found by ``which``. +- Fix for when the dart executable can't be found by `which`. ## 0.0.1 From 512cf9fa9e25430161d76a7039a4ac284fd87f56 Mon Sep 17 00:00:00 2001 From: pquitslund Date: Tue, 10 Feb 2015 10:42:35 -0800 Subject: [PATCH 4/4] If-block rethink. --- lib/cli_util.dart | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/cli_util.dart b/lib/cli_util.dart index ac767b2..683bef7 100644 --- a/lib/cli_util.dart +++ b/lib/cli_util.dart @@ -37,17 +37,18 @@ Directory getSdkDir([List cliArgs]) { // Try and locate the VM using 'which'. String executable = whichSync('dart', orElse: () => null); - if (executable == null) return null; - // In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links. - Link link = new Link(executable); - if (link.existsSync()) { - executable = link.resolveSymbolicLinksSync(); - } + if (executable != null) { + // In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links. + Link link = new Link(executable); + if (link.existsSync()) { + executable = link.resolveSymbolicLinksSync(); + } - File dartVm = new File(executable); - Directory dir = dartVm.parent.parent; - if (_isSdkDir(dir)) return dir; + File dartVm = new File(executable); + Directory dir = dartVm.parent.parent; + if (_isSdkDir(dir)) return dir; + } return null; }