-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
28 lines (25 loc) · 815 Bytes
/
run.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
const fs = require("mz/fs");
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function main() {
const filename = process.argv[2];
if (!filename) {
console.log("Please provide a .small file.");
return;
}
const astFilename = filename.replace(".small", ".ast");
const jsFilename = filename.replace(".small", ".js");
await myExec(`node parse.js ${filename}`);
await myExec(`node generate.js ${astFilename}`);
// await myExec(`node ${jsFilename}`);
}
async function myExec(command) {
const output = await exec(command);
if (output.stdout) {
process.stdout.write(output.stdout);
}
if (output.stderr) {
process.stdout.write(output.stderr);
}
}
main().catch(err => console.log(err.stack));