Skip to content

Commit 06b9759

Browse files
committed
fix chokidar interval param
1 parent a402a55 commit 06b9759

File tree

14 files changed

+167
-91
lines changed

14 files changed

+167
-91
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ tsnd --respawn server.ts
4747
- `--interval` - Polling interval (ms)
4848
- `--debounce` - Debounce file change events (ms, non-polling mode)
4949
- `--clear` (`--cls`) Will clear screen on restart
50-
- `--watch` - Explicitly add files or folders to watch and restart on change (list separated by commas)
50+
- `--watch` - Explicitly add arbitrary files or folders to watch and restart on change (list separated by commas, [chokidar](https://github.com/paulmillr/chokidar) patterns)
5151
- `--exit-child` - Adds 'SIGTERM' exit handler in a child process.
52+
- `--rs` - Allow to restart with "rs" line entered in stdio, enabled by default, may turn it off `--rs false`
5253

5354
**Caveats and points of notice:**
5455

bin/ts-node-dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var opts = minimist(devArgs, {
6666
project: 'P',
6767
'restart-terminated': 'rt'
6868
},
69-
default: { deps: true, notify: true, rs: true },
69+
default: { deps: true, notify: true, rs: true, 'type-check': true },
7070
unknown: function(arg) {
7171
unknown.push(arg)
7272
return true

lib/compiler.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ var compiler = {
201201
files: options['files'] || true,
202202
}
203203
try {
204-
// if (compiler.service && compiler.service.enable) {
205-
// compiler.service.enable(false)
206-
// }
207-
compiler.service = register(tsNodeOptions)
204+
compiler.service = register(tsNodeOptions)
208205
} catch (e) {
209206
console.log(e)
210207
return
@@ -260,8 +257,9 @@ var compiler = {
260257
)
261258
} catch (e) {
262259
console.log('Compilation error in', fileName)
263-
code = 'throw ' + 'new Error(' + JSON.stringify(e.message) + ')' + ';'
264-
writeCompiled(code)
260+
const errorCode =
261+
'throw ' + 'new Error(' + JSON.stringify(e.message) + ')' + ';'
262+
writeCompiled(errorCode)
265263
compiler.registerTsNode()
266264
}
267265
},

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ module.exports = function(script, scriptArgs, nodeArgs, opts) {
4848
function initWatcher () {
4949
var watcher = chokidar.watch([], {
5050
usePolling: opts.poll,
51-
interval: parseInt(opts.interval)
51+
interval: parseInt(opts.interval) || undefined,
52+
5253
})
5354
watcher.on('change', restart)
5455

@@ -105,10 +106,10 @@ module.exports = function(script, scriptArgs, nodeArgs, opts) {
105106
//var compileReqWatcher = filewatcher({ forcePolling: opts.poll })
106107
if (compileReqWatcher) {
107108
compileReqWatcher.close()
108-
}
109+
}
109110
compileReqWatcher = chokidar.watch([], {
110111
usePolling: opts.poll,
111-
interval: parseInt(opts.interval)
112+
interval: parseInt(opts.interval) || undefined
112113
})
113114
var currentCompilePath
114115
fs.writeFileSync(compiler.getCompileReqFilePath(), '')

package.json

Lines changed: 7 additions & 6 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.45",
3+
"version": "1.0.0-pre.47",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",
@@ -39,9 +39,9 @@
3939
"scripts": {
4040
"tsnd": "node ./bin/ts-node-dev",
4141
"ts-node-dev": "node ./bin/ts-node-dev",
42-
"test": "ts-node test/index.ts",
43-
"ci": "yarn test",
44-
"manual": "node ./bin/ts-node-dev --rt 5 --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/manual/test-script test-arg --fd"
42+
"test": "ts-node --transpile-only test/index.ts",
43+
"ci": "yarn test",
44+
"manual": "node ./bin/ts-node-dev --rt 5 --exit-child --tree-kill --clear -r tsconfig-paths/register -r ./test/manual/add-require -r ./test/manual/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/manual/test-script test-arg --fd"
4545
},
4646
"dependencies": {
4747
"chokidar": "^3.4.0",
@@ -54,13 +54,14 @@
5454
"rimraf": "^2.6.1",
5555
"source-map-support": "^0.5.12",
5656
"tree-kill": "^1.2.2",
57-
"ts-node": "*",
57+
"ts-node": "^8.10.2",
5858
"tsconfig": "^7.0.0"
5959
},
6060
"devDependencies": {
6161
"@types/fs-extra": "^9.0.1",
6262
"@types/node": "^8.0.4",
6363
"@types/tape": "^4.13.0",
64+
"@types/touch": "^3.1.1",
6465
"coffee-script": "^1.8.0",
6566
"eslint": "^2.0.0",
6667
"eslint-config-airbnb-base": "^3.0.1",
@@ -71,6 +72,6 @@
7172
"tape": "^5.0.1",
7273
"touch": "^1.0.0",
7374
"tsconfig-paths": "^3.3.1",
74-
"typescript": "^3.7.4"
75+
"typescript": "^3.9.5"
7576
}
7677
}

test/fixture/dep-ts-error.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const fn = (x: number) => {
2+
return 'v1'
3+
}
4+

test/fixture/folder/some-file

Whitespace-only changes.

test/fixture/folder2/nest/other-file

Whitespace-only changes.

test/fixture/simple.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
import { fn } from './dep'
2-
//import { A } from './dep-interface'
3-
// const str: string = process.argv[2]
4-
// const obj: A = {
5-
// a: '1',
6-
// b: 2
7-
// }
82

93
console.log(fn(1))

test/fixture/with-error.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { fn } from './dep-ts-error'
2+
3+
// @ts-expect-erro
4+
console.log(fn('1'))

0 commit comments

Comments
 (0)