Skip to content

Commit 3641048

Browse files
committed
sume bugs
1 parent 0f7f85c commit 3641048

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

lib/index.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
3333
if (cfg.dedupe) process.env.NODE_DEV_PRELOAD = __dirname + '/dedupe';
3434

3535
var watcher = filewatcher({ forcePolling: opts.poll });
36-
36+
var starting = false
3737
watcher.on('change', function (file) {
3838
if (file === compiler.tsConfigPath) {
3939
notify('Reinitializing TS compilation');
@@ -42,8 +42,10 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
4242
/* eslint-disable no-octal-escape */
4343
if (cfg.clear) process.stdout.write('\033[2J\033[H');
4444
notify('Restarting', file + ' has been modified');
45-
compiler.compileChanged(file)
46-
//watcher.removeAll();
45+
compiler.compileChanged(file)
46+
if (starting) return
47+
watcher.removeAll();
48+
starting = true
4749
if (child) {
4850
// Child is still running, restart upon exit
4951
child.on('exit', start);
@@ -72,7 +74,7 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
7274
cwd: process.cwd(),
7375
env: process.env
7476
});
75-
77+
starting = false
7678
var compileReqWatcher = filewatcher({ forcePolling: opts.poll });
7779
var currentCompilePath
7880
fs.writeFileSync(compiler.getCompileReqFilePath(), '');
@@ -98,12 +100,13 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
98100
})
99101
})
100102
child.on('message', function (message) {
101-
if (currentCompilePath == message.compiledPath) return
103+
if (!message.compiledPath || currentCompilePath === message.compiledPath) return
102104
currentCompilePath = message.compiledPath
103105
compiler.compile(message)
104106
});
105107

106108
child.on('exit', function (code) {
109+
if (!child) return
107110
if (!child.respawn) process.exit(code);
108111
child = undefined;
109112
});
@@ -135,14 +138,15 @@ module.exports = function (script, scriptArgs, nodeArgs, opts) {
135138
}
136139

137140
function stop(willTerminate) {
138-
// if (!child || child.stopping) {
139-
// //console.log('stop no child')
140-
// return
141-
// };
141+
if (!child || child.stopping) {
142+
return
143+
};
142144
child.stopping = true
143145
child.respawn = true;
144-
child.disconnect();
145-
if (!willTerminate) child.kill('SIGTERM');
146+
if (child.connected === undefined || child.connected === true) {
147+
child.disconnect();
148+
if (!willTerminate) child.kill('SIGTERM');
149+
}
146150
}
147151

148152
// Relay SIGTERM

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-node-dev",
3-
"version": "1.0.0-pre.27",
3+
"version": "1.0.0-pre.30",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",

0 commit comments

Comments
 (0)