Changes child_process.spawn to child_process.fork to create new node process to run server.js.
Currently bin/ungit creates a new child process using spawn with the first argument of process, which is expected to be "node" or in some OS (apparently) "nodejs". When running this script from other programs, for example as part of a VSCode extension, this expectation does not hold and the first argument is actually "Code.exe". Trying to spawn the ungit server there fails for obvious reasons.
Since the goal is to create a new node process (with the same one that is already running), we can shorthand it by using fork:
The child_process.fork() method is a special case of child_process.spawn() used specifically to spawn new Node.js processes.
Adding the silent option is necessary to keep the event handlers the same.
Changes
child_process.spawn
tochild_process.fork
to create new node process to runserver.js
.Currently
bin/ungit
creates a new child process usingspawn
with the first argument ofprocess
, which is expected to be"node"
or in some OS (apparently)"nodejs"
. When running this script from other programs, for example as part of a VSCode extension, this expectation does not hold and the first argument is actually"Code.exe"
. Trying to spawn the ungit server there fails for obvious reasons.Since the goal is to create a new node process (with the same one that is already running), we can shorthand it by using
fork
:Adding the
silent
option is necessary to keep the event handlers the same.