1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

Add a Node.js code watcher. It's not a separate process, so it can check require.cache for files it should watch. Currently unused due to missing SIGHUP handlers.

This commit is contained in:
Simo Kinnunen 2014-05-14 11:01:59 +09:00
parent ef7fd77322
commit 002c9e5fd9

21
lib/util/refresh.js Normal file
View file

@ -0,0 +1,21 @@
var fs = require('fs')
var watchers = Object.create(null)
function refresh() {
process.kill('SIGHUP')
}
function collect() {
Object.keys(require.cache).forEach(function(path) {
if (!watchers[path]) {
if (path.indexOf('node_modules') === -1) {
watchers[path] = fs.watch(path, refresh)
}
}
})
}
module.exports = function() {
collect()
}