How to use the nodemon/lib/utils/bus.on function in nodemon

To help you get started, we’ve selected a few nodemon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JacksonGariety / gulp-nodemon / index.js View on Github external
} 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
github JacksonGariety / gulp-nodemon / index.js View on Github external
// 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()
      }

nodemon

Simple monitor script for use during development of a Node.js app.

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis