Skip to content

Commit dd54c21

Browse files
authored
actually stop the watcher (#370)
* actually stop the watcher. * 60s timeout * return a promise * fixup
1 parent a25e3d1 commit dd54c21

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

.taprc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ jsx: false
33
jobs: 1
44
reporter: terse
55
check-coverage: false
6+
timeout: 60

lib/watch/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const watch = function (args, ignoreWatch, verboseWatch) {
2626
}
2727
if (watcher) {
2828
allStop = true
29-
watcher.close()
29+
return watcher.close()
3030
}
3131
}
3232

@@ -109,6 +109,8 @@ const watch = function (args, ignoreWatch, verboseWatch) {
109109
stop(watcher)
110110
})
111111

112+
emitter.stop = stop.bind(null, watcher)
113+
112114
return emitter
113115
}
114116

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@
9393
"tsd": {
9494
"directory": "test"
9595
}
96-
}
96+
}

test/start.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ test('should reload the env on restart when watching', async (t) => {
621621
const fastifyEmitter = await requireUncached('../start').start(argv)
622622

623623
t.teardown(async () => {
624-
await fastifyEmitter.emit('close')
625-
await process.chdir(cwd)
624+
await fastifyEmitter.stop()
625+
process.chdir(cwd)
626626
})
627627

628628
await once(fastifyEmitter, 'ready')

0 commit comments

Comments
 (0)