Skip to content

Commit d2faab9

Browse files
committed
add --error-recompile flag
1 parent fbe1eaf commit d2faab9

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

bin/ts-node-dev

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ var opts = minimist(devArgs, {
3434
'tree-kill',
3535
'clear', 'cls',
3636
'exit-child',
37-
'rs'
37+
'rs',
38+
'error-recompile'
3839
],
3940
string: [
4041
'compiler',
@@ -54,7 +55,7 @@ var opts = minimist(devArgs, {
5455
'interval',
5556
'debounce',
5657
'watch',
57-
'restart-terminated'
58+
'restart-terminated',
5859
],
5960
alias: {
6061
transpileOnly: 'T',

lib/compiler.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ var compiler = {
205205
compilerOptions: compilerOptions,
206206
files: options['files'] || true,
207207
}
208+
208209
try {
209210
compiler.service = register(tsNodeOptions)
210211
} catch (e) {
@@ -271,8 +272,11 @@ var compiler = {
271272
// should we really re-register ts-node?
272273
compiler.registerTsNode()
273274

275+
if (!compiler.options['error-recompile']) {
276+
return
277+
}
274278
const timeoutMs =
275-
parseInt(process.env.TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT) || 2500
279+
parseInt(process.env.TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT) || 5000
276280
const errorHandler = () => {
277281
clearTimeout(compiler._errorCompileTimeout)
278282
compiler._errorCompileTimeout = setTimeout(() => {

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.48",
3+
"version": "1.0.0-pre.49",
44
"description": "Compiles your TS app and restarts when files are modified.",
55
"keywords": [
66
"restart",

test/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ const notFoundSource = `export const fn = (x: number) => {
113113
return 'v1'
114114
}
115115
`
116-
test('It restarts when not found module added', async (t) => {
117-
const ps = spawnTsNodeDev('--respawn with-not-found.ts', {
116+
test.only('It recompiles file on error and restarts', async (t) => {
117+
const ps = spawnTsNodeDev('--respawn --error-recompile with-not-found.ts', {
118118
//stdout: true,
119119
env: {
120120
TS_NODE_DEV_ERROR_RECOMPILE_TIMEOUT: 250,
@@ -144,7 +144,7 @@ test('It handles allowJs option and loads JS modules', async (t) => {
144144
await ps.exit()
145145
})
146146

147-
test('It allows use TS Transformers', async (t) => {
147+
test('It allows to use TS Transformers', async (t) => {
148148
const cOptions = { plugins: [{ transform: 'ts-nameof', type: 'raw' }] }
149149
const ps = spawnTsNodeDev(
150150
[
@@ -159,7 +159,7 @@ test('It allows use TS Transformers', async (t) => {
159159
await ps.exit()
160160
})
161161

162-
test('It allows use custom TS Transformers', async (t) => {
162+
test('It allows to use custom TS Transformers', async (t) => {
163163
const cOptions = { plugins: [{ transform: __dirname + '/transformer.ts' }] }
164164
const ps = spawnTsNodeDev(
165165
[

0 commit comments

Comments
 (0)