-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate-test
41 lines (34 loc) · 928 Bytes
/
generate-test
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
#!/usr/bin/env node
'use strict';
try {
require('source-map-support').install();
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') throw err;
}
const child_process = require('child_process');
const exec = async (cmd, cwd = __dirname) => {
return new Promise((resolve, reject) => {
child_process.exec(cmd, { cwd }, (error, stdout, stderr) => {
if (error) reject(new Error(`exec error ${error}: ${stderr}`));
resolve(stdout);
});
});
};
try {
(async () => {
await exec('npm run compile');
const generator = require('./build/tests/generator');
let use = 'dmg';
const argv = process.arv.slice(2);
if (['calc', 'smogon'].includes(argv[0])) {
use = 'calc';
argv.shift();
} else if (args[0] === 'dmg') {
argv.shift();
}
console.log(generator.generate(argv.join(' '), use));
})();
} catch (e) {
console.error(e.message);
process.exit(1);
}