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 /// Set of flags and options passed to the compiler | 5 /// Set of flags and options passed to the compiler |
6 library dev_compiler.src.options; | 6 library dev_compiler.src.options; |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 defaultsTo: 'iojs') | 304 defaultsTo: 'iojs') |
305 ..addOption('dump-info-file', | 305 ..addOption('dump-info-file', |
306 abbr: 'f', | 306 abbr: 'f', |
307 help: 'Dump info json file (requires dump-info)', | 307 help: 'Dump info json file (requires dump-info)', |
308 defaultsTo: null)); | 308 defaultsTo: null)); |
309 | 309 |
310 /// Tries to find the `lib/runtime/` directory of the dev_compiler package. This | 310 /// Tries to find the `lib/runtime/` directory of the dev_compiler package. This |
311 /// works when running devc from it's sources or from a snapshot that is | 311 /// works when running devc from it's sources or from a snapshot that is |
312 /// activated via `pub global activate`. | 312 /// activated via `pub global activate`. |
313 String _computeRuntimeDir() { | 313 String _computeRuntimeDir() { |
314 var scriptUri = Platform.script; | 314 var scriptPath = path.fromUri(Platform.script); |
315 var scriptPath = scriptUri.path; | |
316 var file = path.basename(scriptPath); | 315 var file = path.basename(scriptPath); |
317 var dir = path.dirname(scriptPath); | 316 var dir = path.dirname(scriptPath); |
318 var lastdir = path.basename(dir); | 317 var lastdir = path.basename(dir); |
319 dir = path.dirname(dir); | 318 dir = path.dirname(dir); |
320 | 319 |
321 // Both the source devc.dart and the snapshot generated by pub global activate | 320 // Both the source devc.dart and the snapshot generated by pub global activate |
322 // are under a bin folder. | 321 // are under a bin folder. |
323 if (lastdir != 'bin') return null; | 322 if (lastdir != 'bin') return null; |
324 | 323 |
325 // And both under a project directory containing a pubspec.lock file. | 324 // And both under a project directory containing a pubspec.lock file. |
(...skipping 26 matching lines...) Expand all Loading... |
352 // The pub-cache directory is two levels up, but we verify that the layout | 351 // The pub-cache directory is two levels up, but we verify that the layout |
353 // looks correct. | 352 // looks correct. |
354 if (path.basename(dir) != 'dev_compiler') return null; | 353 if (path.basename(dir) != 'dev_compiler') return null; |
355 dir = path.dirname(dir); | 354 dir = path.dirname(dir); |
356 if (path.basename(dir) != 'global_packages') return null; | 355 if (path.basename(dir) != 'global_packages') return null; |
357 dir = path.dirname(dir); | 356 dir = path.dirname(dir); |
358 return path.join(dir, cacheDir, 'lib', 'runtime'); | 357 return path.join(dir, cacheDir, 'lib', 'runtime'); |
359 } | 358 } |
360 return null; | 359 return null; |
361 } | 360 } |
OLD | NEW |