Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: lib/src/util/io.dart

Issue 1133603005: pkg/test: handle symlinked dart executable (Closed) Base URL: https://github.com/dart-lang/test.git@master
Patch Set: mark as dev dep Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | pubspec.yaml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util/io.dart
diff --git a/lib/src/util/io.dart b/lib/src/util/io.dart
index dbe34f4e01ff7965590232a7a83c39c58b672b53..fa52b370e94513a4eb07eed1e4cba66f7af826d9 100644
--- a/lib/src/util/io.dart
+++ b/lib/src/util/io.dart
@@ -20,9 +20,18 @@ const _newline = 0xA;
/// The ASCII code for a carriage return character.
const _carriageReturn = 0xD;
+String _sdkDir;
nweiz 2015/05/15 20:04:50 For lazy top-level variables, I like to take advan
kevmoo 2015/05/21 17:46:22 Done.
+
/// The root directory of the Dart SDK.
-final String sdkDir =
- p.dirname(p.dirname(Platform.executable));
+String get sdkDir {
nweiz 2015/05/15 20:04:50 Add a TODO to get rid of this variable when Platfo
kevmoo 2015/05/21 17:46:22 Not sure if that's going to happen, given the curr
nweiz 2015/05/21 19:06:01 A TODO to simplify it when Platform.executable is
+ if (_sdkDir == null) {
+ // This may fail on Mac if `dart` is run directly from the PATH environment
nweiz 2015/05/15 20:04:50 What does "run directly from the PATH environment"
kevmoo 2015/05/21 17:46:22 Acknowledged.
+ // See https://code.google.com/p/dart/issues/detail?id=21791
nweiz 2015/05/15 20:04:50 What does this issue have to do with it?
kevmoo 2015/05/21 17:46:22 Acknowledged.
+ var path = new File(Platform.executable).resolveSymbolicLinksSync();
nweiz 2015/05/15 20:04:50 What if the bin directory is symlinked rather than
kevmoo 2015/05/21 17:46:22 This still works. resolveSymbolicLinks does the wo
+ _sdkDir = p.dirname(p.dirname(path));
+ }
+ return _sdkDir;
+}
/// The version of the Dart SDK currently in use.
final Version _sdkVersion = new Version.parse(
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698