| OLD | NEW | 
|---|
| 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 library code_transformers.src.dart_sdk; | 5 library code_transformers.src.dart_sdk; | 
| 6 | 6 | 
| 7 import 'dart:convert' as convert; | 7 import 'dart:convert' as convert; | 
| 8 import 'dart:io' show Directory, File, Platform, Process; | 8 import 'dart:io' show File, Platform, Process; | 
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; | 
| 10 | 10 | 
| 11 | 11 | 
| 12 /// Attempts to provide the current Dart SDK directory. | 12 /// Attempts to provide the current Dart SDK directory. | 
| 13 /// | 13 /// | 
| 14 /// This will return null if the SDK cannot be found | 14 /// This will return null if the SDK cannot be found | 
| 15 /// | 15 /// | 
| 16 /// Note that this may not be correct when executing outside of `pub`. | 16 /// Note that this may not be correct when executing outside of `pub`. | 
| 17 String get dartSdkDirectory { | 17 String get dartSdkDirectory { | 
| 18 | 18 | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 40 | 40 | 
| 41   var parts = path.split(dartDir); | 41   var parts = path.split(dartDir); | 
| 42   // If the dart executable is within the sdk dir then get the root. | 42   // If the dart executable is within the sdk dir then get the root. | 
| 43   if (parts.contains('dart-sdk')) { | 43   if (parts.contains('dart-sdk')) { | 
| 44     var dartSdkDir = path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1)); | 44     var dartSdkDir = path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1)); | 
| 45     if (isSdkDir(dartSdkDir)) return dartSdkDir; | 45     if (isSdkDir(dartSdkDir)) return dartSdkDir; | 
| 46   } | 46   } | 
| 47 | 47 | 
| 48   return null; | 48   return null; | 
| 49 } | 49 } | 
| 50 |  | 
| 51 /// Variant of [dartSdkDirectory] which includes additional cases only |  | 
| 52 /// typically encountered in Dart's testing environment. |  | 
| 53 String get testingDartSdkDirectory { |  | 
| 54   var sdkDir = dartSdkDirectory; |  | 
| 55   if (sdkDir == null) { |  | 
| 56     // If we cannot find the SDK dir, then assume this is being run from Dart's |  | 
| 57     // source directory and this script is the main script. |  | 
| 58     sdkDir = path.join( |  | 
| 59         path.dirname(path.fromUri(Platform.script)), '..', '..', '..', 'sdk'); |  | 
| 60   } |  | 
| 61   return sdkDir; |  | 
| 62 } |  | 
| OLD | NEW | 
|---|