From 1bcc7a0a5a22f8e424c2908aadfee8208dbdc2c6 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 19 May 2015 16:38:43 -0700 Subject: [PATCH] Support an executable in a symlinked directory. R=pquitslund@google.com Review URL: https://chromiumcodereview.appspot.com//1132913003 --- CHANGELOG.md | 4 ++++ lib/cli_util.dart | 7 +++++++ pubspec.yaml | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7271432..85af3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.0.1+2 + +- Support an executable in a symlinked directory. + ## 0.0.1+1 - Fix for when the dart executable can't be found by `which`. diff --git a/lib/cli_util.dart b/lib/cli_util.dart index 683bef7..aff2c67 100644 --- a/lib/cli_util.dart +++ b/lib/cli_util.dart @@ -6,6 +6,7 @@ library cli_util; import 'dart:io'; +import 'package:path/path.dart' as p; import 'package:which/which.dart'; /// Return the path to the current Dart SDK. This will return `null` if we are @@ -45,6 +46,12 @@ Directory getSdkDir([List cliArgs]) { executable = link.resolveSymbolicLinksSync(); } + Link parentLink = new Link(p.dirname(executable)); + if (parentLink.existsSync()) { + executable = p.join( + parentLink.resolveSymbolicLinksSync(), p.basename(executable)); + } + File dartVm = new File(executable); Directory dir = dartVm.parent.parent; if (_isSdkDir(dir)) return dir; diff --git a/pubspec.yaml b/pubspec.yaml index 80f21e1..c27866d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,12 @@ name: cli_util -version: 0.0.1+1 +version: 0.0.1+2 author: Dart Team description: A library to help in building Dart command-line apps. homepage: https://github.com/dart-lang/cli_util environment: sdk: '>=1.0.0 <2.0.0' dependencies: + path: '>=1.0.0 <2.0.0' which: '>=0.1.2 <0.2.0' dev_dependencies: unittest: '>=0.11.0 <0.12.0'