Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
nodemon = require('nodemon')
}
// Our script
var script = nodemon(options)
, originalOn = script.on
, originalListeners = bus.listeners('restart')
// Allow for injection of tasks on file change
if (options.tasks) {
// Remove all 'restart' listeners
bus.removeAllListeners('restart')
// Place our listener in first position
bus.on('restart', function (files){
if (!options.quiet) nodemonLog('running tasks...')
if (typeof options.tasks === 'function') run(options.tasks(files))
else run(options.tasks)
})
// Re-add all other listeners
for (var i = 0; i < originalListeners.length; i++) {
bus.on('restart', originalListeners[i])
}
}
// Capture ^C
process.once('SIGINT', function () {
script.emit('quit')
script.quitEmitted = true
// Allow for injection of tasks on file change
if (options.tasks) {
// Remove all 'restart' listeners
bus.removeAllListeners('restart')
// Place our listener in first position
bus.on('restart', function (files){
if (!options.quiet) nodemonLog('running tasks...')
if (typeof options.tasks === 'function') run(options.tasks(files))
else run(options.tasks)
})
// Re-add all other listeners
for (var i = 0; i < originalListeners.length; i++) {
bus.on('restart', originalListeners[i])
}
}
// Capture ^C
process.once('SIGINT', function () {
script.emit('quit')
script.quitEmitted = true
})
script.on('exit', function () {
// Ignore exit event during restart
if (script.quitEmitted) {
// Properly signal async completion by calling the callback provided by gulp
if (typeof options.done === "function") {
options.done()
}