1 | var fs = require('fs-extra');
|
2 |
|
3 |
|
4 | var numFiles = process.argv.length - 1;
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var requires = {};
|
11 |
|
12 | process.argv.forEach(function(val, index, array) {
|
13 |
|
14 | if (index === 0) {
|
15 | return;
|
16 | }
|
17 |
|
18 | fs.readFile(val, function(err, data) {
|
19 | if (err) {
|
20 | return;
|
21 | }
|
22 |
|
23 | var re = new RegExp('goog\\.provide\\(\'(.*)\'\\);');
|
24 |
|
25 | data.toString().split('\n').forEach(function(line) {
|
26 | var match = line.match(re);
|
27 | if (match) {
|
28 | requires[match[1]] = true;
|
29 | }
|
30 | });
|
31 |
|
32 | if (--numFiles === 0) {
|
33 | Object.keys(requires).sort().forEach(function(key) {
|
34 | process.stdout.write('goog.require(\'' + key + '\');\n');
|
35 | });
|
36 | }
|
37 |
|
38 | });
|
39 |
|
40 | });
|