Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 4454e81

Browse files
author
Nikhil Thorat
authored
Update watch demo to not start a new http server every compile (#101)
1 parent 0716131 commit 4454e81

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/watch-demo

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ const watchify = spawn(cmd, [startTsFilePath, '-p', '[tsify]', '-v', '--debug',
2626
watchify.stdout.pipe(process.stdout);
2727
watchify.stderr.pipe(process.stderr);
2828

29+
let httpServerStarted = false;
30+
2931
console.log('Waiting for initial compile...');
3032
watchify.stderr.on('data', (data) => {
3133
if (data.toString().includes(`written to ${path.dirname(startTsFilePath)}`)) {
32-
const httpCmd = path.join('node_modules', '.bin', 'http-server');
33-
const httpServer = spawn(httpCmd, ['-c-1'], { detached: false});
34-
httpServer.stdout.pipe(process.stdout);
35-
httpServer.stderr.pipe(process.stderr);
34+
if (!httpServerStarted) {
35+
const httpCmd = path.join('node_modules', '.bin', 'http-server');
36+
const httpServer = spawn(httpCmd, ['-c-1'], { detached: false});
37+
httpServer.stdout.pipe(process.stdout);
38+
httpServer.stderr.pipe(process.stderr);
39+
httpServerStarted = true;
40+
}
3641
}
3742
});

0 commit comments

Comments
 (0)