mirror of
https://github.com/msojocs/wx-compiler.git
synced 2025-07-19 00:00:04 +08:00
25 lines
670 B
JavaScript
25 lines
670 B
JavaScript
const fs = require("fs");
|
|
const compiler = require("./wcc");
|
|
|
|
const args = process.argv.slice(2);
|
|
const [type, p] = args;
|
|
// console.log('type:', type, '; options path:', p)
|
|
const optionsData = fs.readFileSync(p).toString();
|
|
const options = JSON.parse(optionsData);
|
|
|
|
(async () => {
|
|
try {
|
|
const result = await compiler[type](options);
|
|
console.log('---------------result------------------')
|
|
if (typeof result === "string") {
|
|
process.stdout.write(result);
|
|
process.exitCode = 1
|
|
process.exit(1)
|
|
} else {
|
|
process.stdout.write(JSON.stringify(result));
|
|
}
|
|
}catch (err) {
|
|
// console.error('conpile.js error ->' + err)
|
|
}
|
|
})();
|