@@ -13,6 +13,7 @@ import 'package:logging/logging.dart' show Level;
13
13
import 'package:path/path.dart' as path;
14
14
import 'package:yaml/yaml.dart' ;
15
15
16
+ const String _V8_BINARY_DEFAULT = 'node' ;
16
17
const bool _CLOSURE_DEFAULT = false ;
17
18
18
19
/// Options used to set up Source URI resolution in the analysis context.
@@ -87,7 +88,7 @@ class RunnerOptions {
87
88
/// executable.
88
89
final String v8Binary;
89
90
90
- const RunnerOptions ({this .v8Binary: 'iojs' });
91
+ const RunnerOptions ({this .v8Binary: _V8_BINARY_DEFAULT });
91
92
}
92
93
93
94
/// General options used by the dev compiler and server.
@@ -206,7 +207,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) {
206
207
var htmlReport = args['html-report' ];
207
208
208
209
var v8Binary = args['v8-binary' ];
209
- if (v8Binary == null ) v8Binary = 'iojs' ;
210
+ if (v8Binary == null ) v8Binary = _V8_BINARY_DEFAULT ;
210
211
211
212
var customUrlMappings = < String , String > {};
212
213
for (var mapping in args['url-mapping' ]) {
@@ -321,12 +322,20 @@ final ArgParser argParser = new ArgParser()
321
322
help: 'Output compilation results to html' , defaultsTo: false )
322
323
..addOption ('v8-binary' ,
323
324
help: 'V8-based binary to run JavaScript output with (iojs, node, d8)' ,
324
- defaultsTo: 'iojs' )
325
+ defaultsTo: _V8_BINARY_DEFAULT )
325
326
..addOption ('dump-info-file' ,
326
327
help: 'Dump info json file (requires dump-info)' , defaultsTo: null );
327
328
328
329
// TODO: Switch over to the `pub_cache` package (or the Resource API)?
329
330
331
+ const _ENTRY_POINTS = const [
332
+ 'dartdevc.dart' ,
333
+ 'dev_compiler.dart' ,
334
+ 'devrun.dart'
335
+ ];
336
+
337
+ final _ENTRY_POINT_SNAPSHOTS = _ENTRY_POINTS .map ((f) => "$f .snapshot" );
338
+
330
339
/// Tries to find the `lib/runtime/` directory of the dev_compiler package. This
331
340
/// works when running devc from it's sources or from a snapshot that is
332
341
/// activated via `pub global activate` .
@@ -346,16 +355,13 @@ String _computeRuntimeDir() {
346
355
if (! new File (lockfile).existsSync ()) return null ;
347
356
348
357
// If running from sources we found it!
349
- if (file == 'dartdevc.dart' ||
350
- file == 'dev_compiler.dart' ||
351
- file == 'devrun.dart' ) {
358
+ if (_ENTRY_POINTS .contains (file)) {
352
359
return path.join (dir, 'lib' , 'runtime' );
353
360
}
354
361
355
362
// If running from a pub global snapshot, we need to read the lock file to
356
363
// find where the actual sources are located in the pub cache.
357
- if (file == 'dartdevc.dart.snapshot' ||
358
- file == 'dev_compiler.dart.snapshot' ) {
364
+ if (_ENTRY_POINT_SNAPSHOTS .contains (file)) {
359
365
// Note: this depends on implementation details of pub.
360
366
var yaml = loadYaml (new File (lockfile).readAsStringSync ());
361
367
var info = yaml['packages' ]['dev_compiler' ];
0 commit comments