mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Fix unit tests
This commit is contained in:
parent
8447d3cac5
commit
c74c23b0ff
2 changed files with 8 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { spawn, execSync } from "child_process";
|
||||
import os from "os";
|
||||
|
||||
function escapeArg(arg) {
|
||||
// Shell metacharacters that need escaping
|
||||
|
|
@ -42,7 +43,7 @@ export async function safeSpawn(command, args, options = {}) {
|
|||
// array args (safer, no escaping needed).
|
||||
// See: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
|
||||
let child;
|
||||
if (process.platform === "win32") {
|
||||
if (os.platform() === "win32") {
|
||||
const fullCommand = buildCommand(command, args);
|
||||
child = spawn(fullCommand, { ...options, shell: true });
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ describe("safeSpawn", () => {
|
|||
},
|
||||
});
|
||||
|
||||
mock.module("os", {
|
||||
namedExports: {
|
||||
platform: () => "win32",
|
||||
},
|
||||
});
|
||||
|
||||
// Import after mocking
|
||||
const safeSpawnModule = await import("./safeSpawn.js");
|
||||
safeSpawn = safeSpawnModule.safeSpawn;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue