mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +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:
parent
ef7fd77322
commit
002c9e5fd9
1 changed files with 21 additions and 0 deletions
21
lib/util/refresh.js
Normal file
21
lib/util/refresh.js
Normal 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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue