-
Notifications
You must be signed in to change notification settings - Fork 5
/
bundle.js
43 lines (37 loc) · 954 Bytes
/
bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
let path = require('path'),
fs = require('fs');
let {
buildFromManifest
} = require('./src/packageBuilder.js');
let argv = require('yargs').argv;
let manifest = argv._[0];
let modules = (argv.modules || '').split(',');
let codes = (argv.code || '').split(',');
if (!manifest || path.extname(manifest).toLowerCase() !== '.json') {
console.log("expected manifest .json file as argument");
process.exit(1);
}
let output = argv.o || path.join(
path.dirname(manifest),
path.basename(manifest, '.json')
) + '.js';
buildFromManifest(
path.dirname(manifest),
JSON.parse(
fs.readFileSync(manifest)
),
modules,
codes
).then(result => {
fs.writeFile(output, result, (err) => {
if (err) {
console.log(err);
process.exit(1);
}
console.log(`${output} created.`);
});
}).catch(err => {
console.log(err);
process.exit(1);
});