From 8cc144bc726e3288bc99a13cba3fb0d84a92b30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loi=CC=88c=20Correnson?= <loic.correnson@cea.fr> Date: Thu, 28 Apr 2022 16:23:58 +0200 Subject: [PATCH] [ivette] fix PWD vs. Sys.getcwd pb. from Node --- ivette/src/dome/misc/system.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ivette/src/dome/misc/system.ts b/ivette/src/dome/misc/system.ts index 7c726722647..8a6eb07fbbf 100644 --- a/ivette/src/dome/misc/system.ts +++ b/ivette/src/dome/misc/system.ts @@ -537,21 +537,23 @@ export function spawn( return new Promise((result, reject) => { const cwd = options ? options.cwd : undefined; - const env = options && options.env ? ({ ...process.env, ...options.env }) : undefined; + const opt = options ? options.env : undefined; + const env = + (cwd || opt) ? { ...process.env, ...opt, 'PWD': cwd } : undefined; const stdin = stdSpec(options && options.stdin, false); const stdout = stdSpec(options && options.stdout, true); const stderr = stdSpec(options && options.stderr, true); const stdio = [stdin.io, stdout.io, stderr.io]; - const opt: Exec.ForkOptions = { cwd, env, stdio }; - const fork = options && options.fork; + const fopt: Exec.ForkOptions = { cwd, env, stdio }; + const forked = options && options.fork; const cargs = args ? args.slice() : []; let child: Exec.ChildProcess | undefined; - if (fork) { + if (forked) { stdio.push('ipc'); - child = Exec.fork(command, cargs, opt); + child = Exec.fork(command, cargs, fopt); } else { - child = Exec.spawn(command, cargs, opt); + child = Exec.spawn(command, cargs, fopt); } if (!child) reject(new Error( -- GitLab