-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg: Use spwan to check perl scripts
This avoids ERR_CHILD_PROCESS_STDIO_MAXBUFFER being called if we have too much output.
- Loading branch information
Showing
4 changed files
with
56 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
/*eslint no-console: "off"*/ | ||
/*eslint no-await-in-loop: "off"*/ | ||
/*global process*/ | ||
|
||
const process = require('process'); | ||
const util = require('util'); | ||
const glob = util.promisify(require('glob').glob); | ||
const execFile = util.promisify(require('child_process').execFile); | ||
const process = require("process"); | ||
const util = require("util"); | ||
const glob = util.promisify(require("glob").glob); | ||
const { spawn } = require("child_process"); | ||
|
||
async function main() { | ||
// 0 = node; 1 = check_perl.js | ||
for (let arg of process.argv.slice(2)) { | ||
for (const arg of process.argv.slice(2)) { | ||
const files = await glob(arg); | ||
for (var i = 0; i < files.length; ++i) { | ||
const path = files[i]; | ||
console.log(`Checking ${path}`); | ||
try { | ||
const { stdout, stderr } = await execFile(`perl`, ['-c', '-CS', '-Ilib', files[i]]); | ||
if (stderr) { | ||
console.error(stderr); | ||
} | ||
|
||
console.log(stdout); | ||
const child = spawn(`perl`, ["-c", "-CS", "-Ilib", path]); | ||
child.stdout.on("data", (data) => console.log("[" + path + "] " + data)); | ||
child.stderr.on("data", (data) => console.error("[" + path + "] " + data)); | ||
child.on("close", (code) => { | ||
console.log("[" + path + "] result: " + code); | ||
process.exitCode = code; | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
console.error("[" + path + "] " + e); | ||
process.exitCode = e.code; | ||
throw e; | ||
} | ||
} | ||
} | ||
|
||
console.log('Done!'); | ||
console.log("Done!"); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters