OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, 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 #library('minfrog'); | |
6 | |
7 #import('lib/node/node.dart'); | |
8 #import('file_system_node.dart'); | |
9 #import('lang.dart'); | |
10 | |
11 void main() { | |
12 // Get the home directory from our executable. | |
13 var homedir = path.dirname(fs.realpathSync(process.argv[1])); | |
14 | |
15 // Note: we create a copy of argv here because the one that is passed in is | |
16 // potentially a JS Array object from outside the sandbox. Hence it will have | |
17 // the wrong prototype. | |
18 var argv = []; | |
19 for (int i = 0; i < process.argv.length; i++) { | |
20 argv.add(process.argv[i]); | |
21 if (i == 1) { | |
22 var terminal = process.env['TERM']; | |
23 if (terminal == null || !terminal.startsWith('xterm')) { | |
24 argv.add('--no_colors'); | |
25 } | |
26 } | |
27 } | |
28 | |
29 if (compile(homedir, argv, new NodeFileSystem())) { | |
30 var code = world.getGeneratedCode(); | |
31 if (options.compileOnly) { | |
32 if (options.outfile != null) { | |
33 print('Compilation succeded. Code generated in: ${options.outfile}'); | |
34 } else { | |
35 print('Compilation succeded.'); | |
36 } | |
37 } else { | |
38 process.argv = [argv[0], argv[1]]; | |
39 process.argv.addAll(options.childArgs); | |
40 // TODO(jmesserly): we shouldn't force the child process to patch argv. | |
41 // Instead, we should be injecting code into the child to fix argv's | |
42 // prototype (and possible the proto of require, process, and console). | |
43 vm.runInNewContext(code, createSandbox()); | |
44 } | |
45 } else { | |
46 process.exit(1); | |
47 } | |
48 } | |
OLD | NEW |