-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.js
49 lines (38 loc) · 1.19 KB
/
build.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
44
45
46
const args = require('args');
const chalk = require('chalk');
const buildDesktop = require('./build/buildDesktop');
const buildWeb = require('./build/buildWeb');
const log = require('./log');
const Targets = {
desktop: buildDesktop,
web: buildWeb,
ios: () => console.error("iOS build not implemented yet"),
android: () => console.error("Android build not implemented yet"),
};
const AllowedTargets = Object.keys(Targets);
function validateType(v) {
if (!v || v === '') return v;
if (AllowedTargets.indexOf(v) === -1) {
console.error(`Unknown target type [${v}], allowed are:\n`);
AllowedTargets.forEach(t => console.error(`\t- ${t}`));
process.exit(-1);
}
return v;
}
args.option("target", "The target ", 'web', validateType);
const options = args.parse(process.argv);
const cwd = process.cwd();
(async function () {
try {
log.info(`Building Phoenix for [${chalk.bold.yellow(options.target)}]...`);
const buildFn = Targets[options.target];
await buildFn({
...options,
cwd
});
log.success('Finished');
} catch (e) {
log.error(e);
process.exit(-1);
}
})();