Update the subprocess handler to take a CWD

This commit is contained in:
Logan Cusano
2024-04-06 01:01:36 -04:00
parent 1df2027a29
commit ea63abcb93

View File

@@ -12,9 +12,15 @@ const runningProcesses = {};
* @param {string[]} args - The arguments to pass to the process.
* @param {boolean} waitForClose - Set this to wait to return until the process exits
*/
export const launchProcess = (processName, args, waitForClose=false) => {
export const launchProcess = (processName, args, waitForClose=false, pcwd=undefined) => {
if (!runningProcesses[processName]) {
const childProcess = spawn(processName, args);
let childProcess;
if (pcwd) {
childProcess = spawn(processName, args, {cwd: pcwd});
}
else {
childProcess = spawn(processName, args);
}
// Store reference to the spawned process
runningProcesses[processName] = childProcess;