awtk/tools/idl_gen/merge.js
2019-05-08 16:23:46 +08:00

22 lines
539 B
JavaScript

const fs = require('fs');
const path = require('path');
if(process.argv.length < 4) {
console.log(`Usage: node merge [idl files list]`);
console.log(`Example: node merge idl.json myidl1.json myidl2.json`);
process.exit(0);
}
let all = []
let files = process.argv.slice(2);
files.map(iter => {
return JSON.parse(fs.readFileSync(iter).toString());
}).forEach(iter => {
all = all.concat(iter);
});
fs.writeFileSync('all.json', JSON.stringify(all, null, ' '));
console.log(`Merged ${JSON.stringify(files)} ==> all.json`);