From ec3db490b20ee4dc8dc17676d328112ef6d848bd Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 12 Jul 2021 23:28:11 +0100 Subject: [PATCH] :notebook: Adds in-code docs to rebiuld app server function --- services/rebuild-app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/rebuild-app.js b/services/rebuild-app.js index 9d00156a..b3ce046c 100644 --- a/services/rebuild-app.js +++ b/services/rebuild-app.js @@ -5,15 +5,17 @@ const { exec } = require('child_process'); module.exports = () => new Promise((resolve, reject) => { - const buildProcess = exec('npm run build'); + const buildProcess = exec('npm run build'); // Trigger the build command - let output = ''; + let output = ''; // Will store console output + // Write output to console, and append to var for returning buildProcess.stdout.on('data', (data) => { process.stdout.write(data); output += data; }); + // Handle errors, by sending the reject buildProcess.on('error', (error) => { reject(Error({ success: false, @@ -22,6 +24,7 @@ module.exports = () => new Promise((resolve, reject) => { })); }); + // When finished, check success, make message and resolve response buildProcess.on('exit', (response) => { const success = response === 0; const message = `Build process exited with ${response}: `