| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library code_transformers.src.dart_sdk; | |
| 6 | |
| 7 import 'dart:convert' as convert; | |
| 8 import 'dart:io' show Directory, Platform, Process; | |
| 9 import 'package:path/path.dart' as path; | |
| 10 | |
| 11 | |
| 12 /// Attempts to provide the current Dart SDK directory. | |
| 13 /// | |
| 14 /// Note that this may not be correct when executing outside of `pub`. | |
| 15 String get dartSdkDirectory { | |
| 16 if (path.split(Platform.executable).length == 1) { | |
| 17 // TODO(blois): make this cross-platform. | |
| 18 // HACK: A single part, hope it's on the path. | |
| 19 var result = Process.runSync('which', ['dart'], | |
| 20 stdoutEncoding: convert.UTF8); | |
| 21 return path.dirname(path.dirname(result.stdout)); | |
| 22 } | |
| 23 var sdkDir = path.dirname(path.absolute(Platform.executable)); | |
| 24 // If there's a sub-dir named dart-sdk then we're most likely executing from | |
| 25 // a dart enlistment build directory. | |
| 26 if (new Directory(path.join(sdkDir, 'dart-sdk')).existsSync()) { | |
| 27 return path.join(sdkDir, 'dart-sdk'); | |
| 28 } | |
| 29 return sdkDir; | |
| 30 } | |
| OLD | NEW |