Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Support an executable in a symlinked directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed May 19, 2015
1 parent d180f7a commit 1bcc7a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
7 changes: 7 additions & 0 deletions lib/cli_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,6 +46,12 @@ Directory getSdkDir([List<String> 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;
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: cli_util
version: 0.0.1+1
version: 0.0.1+2
author: Dart Team <[email protected]>
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'

0 comments on commit 1bcc7a0

Please sign in to comment.