OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 import 'dart:io'; |
| 6 |
| 7 import 'package:path/path.dart' as path; |
| 8 |
| 9 String getSdkPath([List<String> args]) { |
| 10 // Look for --dart-sdk on the command line. |
| 11 if (args != null) { |
| 12 int index = args.indexOf('--dart-sdk'); |
| 13 |
| 14 if (index != -1 && (index + 1 < args.length)) { |
| 15 return args[index + 1]; |
| 16 } |
| 17 |
| 18 for (String arg in args) { |
| 19 if (arg.startsWith('--dart-sdk=')) { |
| 20 return arg.substring('--dart-sdk='.length); |
| 21 } |
| 22 } |
| 23 } |
| 24 |
| 25 // Look in env['DART_SDK'] |
| 26 if (Platform.environment['DART_SDK'] != null) { |
| 27 return Platform.environment['DART_SDK']; |
| 28 } |
| 29 |
| 30 // Use Platform.resolvedExecutable. |
| 31 return path.dirname(path.dirname(Platform.resolvedExecutable)); |
| 32 } |
OLD | NEW |