mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix ranges issue
This commit is contained in:
parent
15785fad73
commit
6b2db6dace
6 changed files with 128 additions and 4 deletions
|
|
@ -43,3 +43,35 @@ export async function safeSpawn(command, args, options = {}) {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To avoid any regression issues on the JS ecosystem,
|
||||
* a py-friendly safeSpawn that avoids shell interpolation
|
||||
* issues (e.g., '<', '>' in version specs).
|
||||
*
|
||||
* TL;DR: add support for shell::false
|
||||
*/
|
||||
export async function safeSpawnPy(command, args, options = {}) {
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn(command, args, { ...options, shell: false });
|
||||
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
child.stdout?.on("data", (data) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
child.stderr?.on("data", (data) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
resolve({ status: code, stdout, stderr });
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
resolve({ status: 1, stdout: "", stderr: error.message || String(error) });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue