Debian Codegraph @

packages/babel-cli/test/fixtures/babel/dir --out-dir --watch --verbose with external dependencies/executor.js

raw symbols SCIP
1 const fs = require("fs");
2 const assert = require("assert");
3 const readline = require("readline");
4
5 // For Node.js <= 10
6 if (!assert.match) assert.match = (val, re) => assert(re.test(val));
7
8 const run = (async function* () {
9 let files = [yield, yield].sort();
10 assert.match(files[0], /src[\\/]index.js -> lib[\\/]index.js/);
11 assert.match(files[1], /src[\\/]main.js -> lib[\\/]main.js/);
12 assert.match(yield, /Successfully compiled 2 files with Babel \(\d+ms\)\./);
13
14 assert.equal(yield, "The watcher is ready.");
15
16 logFile("lib/index.js");
17 logFile("lib/main.js");
18
19 fs.writeFileSync("./file.txt", "Updated!");
20
21 files = [yield, yield].sort();
22 assert.match(files[0], /src[\\/]index.js -> lib[\\/]index.js/);
23 assert.match(files[1], /src[\\/]main.js -> lib[\\/]main.js/);
24 assert.match(yield, /Successfully compiled 2 files with Babel \(\d+ms\)\./);
25
26 logFile("lib/index.js");
27 logFile("lib/main.js");
28 })();
29
30 run.next();
31
32 const batchedStrings = [];
33 let batchId = 0;
34 const rl = readline.createInterface(process.stdin);
35
36 rl.on("line", async function listener(str) {
37 if (!str) return;
38
39 if (str.startsWith("src")) {
40 batchedStrings.push(str);
41 } else {
42 // "src/index.js -> lib/index.js"-like strings don't always come in order,
43 // so we need to collect and sort them before logging.
44 if (batchedStrings.length > 0) {
45 batchedStrings.sort();
46 for (const str of batchedStrings) {
47 console.log(`BATCHED(${batchId})`, str);
48 }
49 batchId++;
50 batchedStrings.length = 0;
51 }
52
53 console.log(str);
54 }
55
56 if ((await run.next(str)).done) {
57 process.exit(0);
58 }
59 });
60
61 function logFile(file) {
62 console.log("EXECUTOR", file, JSON.stringify(fs.readFileSync(file, "utf8")));
63 }
64
65 setTimeout(() => {
66 console.error("EXECUTOR TIMEOUT");
67 process.exit(1);
68 }, 5000);