Skip to content

Commit

Permalink
use which
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Jan 23, 2015
1 parent 25e7f31 commit 2147bce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/grinder_tools.dart
Expand Up @@ -10,6 +10,8 @@ library grinder.tools;
import 'dart:async';
import 'dart:io';

import 'package:which/which.dart';

import 'grinder.dart';

final Directory BIN_DIR = new Directory('bin');
Expand Down Expand Up @@ -55,20 +57,18 @@ Directory getSdkDir([List<String> cliArgs]) {
if (_isSdkDir(sdkDirectory)) return sdkDirectory;

// Try and locate the VM using 'which'.
if (!Platform.isWindows) {
String executable = Process.runSync('which', ['dart']).stdout.trim();

// In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links.
Link link = new Link(executable);
if (link.existsSync()) {
executable = link.resolveSymbolicLinksSync();
}
String executable = whichSync('dart', orElse: () => null);

File dartVm = new File(executable);
Directory dir = dartVm.parent.parent;
if (_isSdkDir(dir)) return dir;
// 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;

return null;
}

Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Expand Up @@ -12,6 +12,7 @@ environment:
dependencies:
args: '>=0.10.0 <0.13.0'
quiver: '>=0.18.0 <0.21.0'
which: '>=0.1.2 <0.2.0'

dev_dependencies:
unittest: any
Expand Down

0 comments on commit 2147bce

Please sign in to comment.