From b326136a0ba9d840c40d3a56350a8674de1ffb7b Mon Sep 17 00:00:00 2001 From: Nikhil Thorat Date: Wed, 6 Sep 2017 15:41:49 -0400 Subject: [PATCH] Update watch demo to not start a new http server every compile --- scripts/watch-demo | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/watch-demo b/scripts/watch-demo index a734f4d315..948289c18b 100755 --- a/scripts/watch-demo +++ b/scripts/watch-demo @@ -26,12 +26,17 @@ const watchify = spawn(cmd, [startTsFilePath, '-p', '[tsify]', '-v', '--debug', watchify.stdout.pipe(process.stdout); watchify.stderr.pipe(process.stderr); +let httpServerStarted = false; + console.log('Waiting for initial compile...'); watchify.stderr.on('data', (data) => { if (data.toString().includes(`written to ${path.dirname(startTsFilePath)}`)) { - const httpCmd = path.join('node_modules', '.bin', 'http-server'); - const httpServer = spawn(httpCmd, ['-c-1'], { detached: false}); - httpServer.stdout.pipe(process.stdout); - httpServer.stderr.pipe(process.stderr); + if (!httpServerStarted) { + const httpCmd = path.join('node_modules', '.bin', 'http-server'); + const httpServer = spawn(httpCmd, ['-c-1'], { detached: false}); + httpServer.stdout.pipe(process.stdout); + httpServer.stderr.pipe(process.stderr); + httpServerStarted = true; + } } });