How to use the nodemon/lib/utils/bus.listeners 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
module.exports = function (options) {
  options = options || {};

  // plug nodemon
  if (options.nodemon && typeof options.nodemon === 'function') {
    nodemon = options.nodemon
    delete options.nodemon
  } 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++) {

nodemon

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

MIT
Latest version published 9 days ago

Package Health Score

93 / 100
Full package analysis