Skip to content

Commit 871ea65

Browse files
committed
rs, child-exit params
1 parent 3d1a242 commit 871ea65

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

bin/ts-node-dev

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ var opts = minimist(devArgs, {
3232
'log-error',
3333
'prefer-ts-exts',
3434
'tree-kill',
35-
'clear', 'cls'
35+
'clear', 'cls',
36+
'exit-child',
37+
'rs'
3638
],
3739
string: [
3840
'compiler',
@@ -62,7 +64,7 @@ var opts = minimist(devArgs, {
6264
compiler: 'C',
6365
project: 'P'
6466
},
65-
default: { deps: true, notify: true },
67+
default: { deps: true, notify: true, rs: true },
6668
unknown: function(arg) {
6769
unknown.push(arg)
6870
return true

lib/child-require-hook.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var preferTs = false
1111
var ignore = [/node_modules/]
1212
var readyFile
1313
var execCheck = false
14+
var exitChild = false
1415
var sourceMapSupportPath
1516

1617
var checkFileScript = join(__dirname, 'check-file-exists.js')
@@ -112,9 +113,11 @@ if (readyFile) {
112113
}
113114
}
114115

115-
process.on('SIGTERM', function() {
116-
console.log('Child got SIGTERM, exiting.')
117-
process.exit()
118-
})
116+
if (exitChild) {
117+
process.on('SIGTERM', function() {
118+
console.log('Child got SIGTERM, exiting.')
119+
process.exit()
120+
})
121+
}
119122

120123
module.exports.registerExtensions = registerExtensions

lib/compiler.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ var compiler = {
7373
}
7474
if (options['exec-check']) {
7575
fileData = fileData.replace('execCheck = false', 'execCheck = true')
76+
}
77+
if (options['exit-child']) {
78+
fileData = fileData.replace('exitChick = false', 'exitChild = true')
7679
}
7780
if (options['ignore'] !== undefined) {
7881
var ignore = options['ignore']

lib/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,20 @@ module.exports = function(script, scriptArgs, nodeArgs, opts) {
5454
if (cfg.deps) log.info('... or add `--no-deps` to use less file handles.')
5555
})
5656

57-
// Read for "rs" from command line
58-
const rl = readline.createInterface({
59-
input: process.stdin,
60-
output: process.stdout,
61-
terminal: false
62-
})
63-
rl.on('line', function(line) {
64-
if (line.trim() === 'rs') {
65-
log.debug('User entered `rs`')
66-
restart('', true)
67-
}
68-
})
57+
// Read for "rs" from command line
58+
if (opts.rs !== false) {
59+
const rl = readline.createInterface({
60+
input: process.stdin,
61+
output: process.stdout,
62+
terminal: false
63+
})
64+
rl.on('line', function(line) {
65+
if (line.trim() === 'rs') {
66+
log.debug('User entered `rs`')
67+
restart('', true)
68+
}
69+
})
70+
}
6971

7072
/**
7173
* Run the wrapped script.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-node-dev",
3-
"version": "1.0.0-pre.42",
3+
"version": "1.0.0-pre.43",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",
@@ -39,7 +39,7 @@
3939
"scripts": {
4040
"ts-node-dev": "node ./bin/ts-node-dev",
4141
"test-node-dev": "tap test/*.js",
42-
"test": "node ./bin/ts-node-dev --tree-kill --clear -r tsconfig-paths/register -r ./test/ts/add-require -r ./test/ts/add-require-2 -r esm -O \"{\\\"module\\\": \\\"es6\\\"}\" --preserve-symlinks --respawn --ignore-watch 'lib' --ignore-watch bin --prefer-ts --debug --poll --interval 1000 --cache-directory .ts-node --inspect -- test/ts/test-script test-arg --fd",
42+
"test": "node ./bin/ts-node-dev --exit-child --tree-kill --clear -r tsconfig-paths/register -r ./test/ts/add-require -r ./test/ts/add-require-2 -r esm -O \"{\\\"module\\\": \\\"es6\\\"}\" --preserve-symlinks --respawn --ignore-watch 'lib' --ignore-watch bin --prefer-ts --debug --poll --interval 1000 --cache-directory .ts-node --inspect -- test/ts/test-script test-arg --fd",
4343
"test-docker": "docker run --rm -v ${PWD}:/app mhart/alpine-node:8.7.0 sh -c 'cd app && node ./bin/ts-node-dev --cache-directory .ts-node test/ts/big'"
4444
},
4545
"dependencies": {

0 commit comments

Comments
 (0)