|
|
@ -1,13 +1,32 @@
|
|
|
|
const { join } = require('path');
|
|
|
|
const { join } = require('path');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
|
|
|
|
|
|
|
const { program } = require('commander');
|
|
|
|
|
|
|
|
|
|
|
|
const config = require(join(process.cwd(), 'builder.config.js'));
|
|
|
|
const config = require(join(process.cwd(), 'builder.config.js'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const validBrowsers = ['chrome', 'firefox', 'edge']
|
|
|
|
|
|
|
|
|
|
|
|
const srcDir = join(process.cwd(), config.root);
|
|
|
|
const srcDir = join(process.cwd(), config.root);
|
|
|
|
const distDir = join(process.cwd(), config.out);
|
|
|
|
const distDir = join(process.cwd(), config.out);
|
|
|
|
|
|
|
|
|
|
|
|
const { builder } = require('./builders');
|
|
|
|
const { builder } = require('./builders');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
program
|
|
|
|
|
|
|
|
.option(`-t, --target <${validBrowsers.join(' | ')}>`, 'set the target browser')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
program.parse(process.argv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const options = program.opts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const target = options.target.toLowerCase() || 'chrome'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!validBrowsers.includes(target)) {
|
|
|
|
|
|
|
|
console.log('Error: invalid target browser, please specify one of the following: ' + validBrowsers.join(', '));
|
|
|
|
|
|
|
|
process.exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process.env.TARGET_BROWSER = target;
|
|
|
|
|
|
|
|
|
|
|
|
if (config.interpreter) {
|
|
|
|
if (config.interpreter) {
|
|
|
|
config.interpreter.forEach((interpreter) => {
|
|
|
|
config.interpreter.forEach((interpreter) => {
|
|
|
|
const input = join(srcDir, interpreter.input);
|
|
|
|
const input = join(srcDir, interpreter.input);
|
|
|
|