OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 var fs = require('fs'); | 5 var fs = require('fs'); |
6 var vm = require('vm'); | 6 var vm = require('vm'); |
7 | 7 |
8 function __load(path) { | 8 function __load(path) { |
9 var data = fs.readFileSync(path); | 9 var data = fs.readFileSync(path); |
10 var script = vm.createScript(data.toString(), path); | 10 var script = vm.createScript(data.toString(), path); |
11 script.runInThisContext(); | 11 script.runInThisContext(); |
12 } | 12 } |
13 | 13 |
14 var args = process.argv.slice(2); | 14 var args = process.argv.slice(2); |
15 var argc = args.length; | 15 var argc = args.length; |
16 | 16 |
17 for (var i = 0; i < argc-1; ++i) { | 17 for (var i = 0; i < argc-1; ++i) { |
18 __load(args[i]); | 18 __load(args[i]); |
19 } | 19 } |
20 | 20 |
21 var main = vm.createScript(args[argc-1] + '.main()', 'main'); | 21 var main = vm.createScript(args[argc-1] + '.main()', 'main'); |
22 main.runInThisContext(); | 22 main.runInThisContext(); |
OLD | NEW |