UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

55 lines (53 loc) 1.65 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../../_virtual/_rolldown/runtime.cjs'); let node_child_process = require("node:child_process"); //#region src/utils/runParallel/bin.ts const stripStderr = (stderr) => { if (!stderr) return; let cleaned = stderr.trim(); cleaned = cleaned.replace(/your \d+x\d+ screen size is bogus\. expect trouble/gi, ""); return cleaned.trim() || void 0; }; /** * Spawn a binary and read its stdout. * @param cmd The name of the binary to spawn. * @param args The arguments for the binary. * @param options Optional option for the spawn function. * @param done Callback function. */ const run = (cmd, args, options, done) => { let normalizedOptions; let normalizedDone; if (typeof options === "function") { normalizedDone = options; normalizedOptions = void 0; } else { normalizedDone = done; normalizedOptions = options; } let executed = false; const ch = (0, node_child_process.spawn)(cmd, args, normalizedOptions ?? {}); let stdout = ""; let stderr = ""; if (ch.stdout) ch.stdout.on("data", (d) => { stdout += d.toString(); }); if (ch.stderr) ch.stderr.on("data", (d) => { stderr += d.toString(); }); ch.on("error", (err) => { if (executed) return; executed = true; normalizedDone(new Error(String(err))); }); ch.on("close", (code) => { if (executed) return; executed = true; const cleanedStderr = stripStderr(stderr); if (cleanedStderr) return normalizedDone(new Error(cleanedStderr)); normalizedDone(null, stdout, code ?? void 0); }); }; //#endregion exports.run = run; //# sourceMappingURL=bin.cjs.map