Skip to content

Commit

Permalink
fix: log start and restarting event
Browse files Browse the repository at this point in the history
  • Loading branch information
erhise committed Mar 3, 2021
1 parent 3b7854b commit 77b9b46
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const child_process = require('child_process');

const path = ensureValidPath(fileName(process.argv[2]));

function logger(msg) {
console.clear();
console.log(new Date(), msg);
}

let sandbox;

function startSandbox() {
console.clear();
console.log(new Date(), "sandbox starting");
sandbox = child_process.spawn('ts-node', [path], {
stdio: 'inherit'
});
Expand All @@ -21,8 +24,10 @@ function startSandbox() {
}

chokidar.watch(path).on('change', () => {
logger('sandbox restarting');
sandbox.kill();
startSandbox();
});

logger('sandbox starting');
startSandbox();

0 comments on commit 77b9b46

Please sign in to comment.