forked from enviPath/enviPy
Current Dev State
This commit is contained in:
45
static/js/ketcher2/node_modules/budo/lib/file-watch.js
generated
vendored
Normal file
45
static/js/ketcher2/node_modules/budo/lib/file-watch.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
// a thin wrapper around chokidar file watching HTML / CSS
|
||||
var watch = require('chokidar').watch
|
||||
var xtend = require('xtend')
|
||||
var Emitter = require('events/')
|
||||
|
||||
var ignores = [
|
||||
'node_modules/**', 'bower_components/**',
|
||||
'.git', '.hg', '.svn', '.DS_Store',
|
||||
'*.swp', 'thumbs.db', 'desktop.ini'
|
||||
]
|
||||
|
||||
module.exports = function (glob, opt) {
|
||||
opt = xtend({
|
||||
usePolling: opt && opt.poll,
|
||||
ignored: ignores,
|
||||
ignoreInitial: true
|
||||
}, opt)
|
||||
|
||||
var emitter = new Emitter()
|
||||
var closed = false
|
||||
var ready = false
|
||||
|
||||
var watcher = watch(glob, opt)
|
||||
watcher.on('add', onWatch.bind(null, 'add'))
|
||||
watcher.on('change', onWatch.bind(null, 'change'))
|
||||
|
||||
// chokidar@1.0.0-r6 only allows close after ready event
|
||||
watcher.once('ready', function () {
|
||||
ready = true
|
||||
if (closed) watcher.close()
|
||||
})
|
||||
|
||||
function onWatch (event, path) {
|
||||
emitter.emit('watch', event, path)
|
||||
}
|
||||
|
||||
emitter.close = function () {
|
||||
if (closed) return
|
||||
if (ready) watcher.close()
|
||||
closed = true
|
||||
}
|
||||
return emitter
|
||||
}
|
||||
|
||||
module.exports.ignores = ignores
|
||||
Reference in New Issue
Block a user