-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
executor.js
47 lines (35 loc) 路 1.2 KB
/
executor.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const fs = require("fs");
const assert = require("assert");
// For Node.js <= 10
if (!assert.match) assert.match = (val, re) => assert(re.test(val));
const run = (function* () {
let files = [yield, yield].sort();
assert.match(files[0], /src[\\/]index.js -> lib[\\/]index.js/);
assert.match(files[1], /src[\\/]main.js -> lib[\\/]main.js/);
assert.match(yield, /Successfully compiled 2 files with Babel \(\d+ms\)\./);
logFile("lib/index.js");
logFile("lib/main.js");
fs.writeFileSync("./file.txt", "Updated!");
files = [yield, yield].sort();
assert.match(files[0], /src[\\/]index.js -> lib[\\/]index.js/);
assert.match(files[1], /src[\\/]main.js -> lib[\\/]main.js/);
assert.match(yield, /Successfully compiled 2 files with Babel \(\d+ms\)\./);
logFile("lib/index.js");
logFile("lib/main.js");
})();
run.next();
process.stdin.on("data", function listener(chunk) {
const str = String(chunk).trim();
if (!str) return;
console.log(str);
if (run.next(str).done) {
process.exit(0);
}
});
function logFile(file) {
console.log("EXECUTOR", file, JSON.stringify(fs.readFileSync(file, "utf8")));
}
setTimeout(() => {
console.error("EXECUTOR TIMEOUT");
process.exit(1);
}, 5000);