diff --git a/server/src/git-serve.ts b/server/src/git-serve.ts index 5ee1ac008..aefaecb8f 100644 --- a/server/src/git-serve.ts +++ b/server/src/git-serve.ts @@ -10,17 +10,19 @@ async function sleep(ms: number) { const EXIT_FILE = '.exit'; const UPDATE_FILE = '.update'; -async function runCommand(command: string) { - const cp = child_process.exec(command); +async function runCommand(command: string, ...args: string[]) { + const cp = child_process.spawn(command, args, { + stdio: 'inherit' + }); await once(cp, 'exit'); } -async function runCommandEatError(command: string) { +async function runCommandEatError(command: string, ...args: string[]) { try { - await runCommand(command); + await runCommand(command, ...args); } catch (e) { - console.warn(command, 'command exited with error, ignoring', e) + console.warn(command, args, 'command exited with error, ignoring', e) } } @@ -31,7 +33,7 @@ async function main() { try { console.log('starting scrypted main...'); - await runCommand('npm run serve-no-build') + await runCommand('npm', 'run', 'serve-no-build') } catch (e) { console.error('scrypted server exited with error', e); @@ -44,14 +46,14 @@ async function main() { if (fs.existsSync(UPDATE_FILE)) { console.log(`${UPDATE_FILE} found. pulling and rebuilding.`); - await runCommandEatError('git reset --hard'); - await runCommandEatError('git pull'); - await runCommandEatError('npm install'); - await runCommandEatError('npm run build'); + await runCommandEatError('git', 'reset', '--hard'); + await runCommandEatError('git', 'pull'); + await runCommandEatError('npm', 'install'); + await runCommandEatError('npm', 'run', 'build'); } console.log(`${EXIT_FILE} not found. restarting momentarily.`); - sleep(10000); + await sleep(10000); } }