How to use the nodemon.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 nathanmarks / jss-theme-reactor / test / watch.js View on Github external
/* eslint-disable no-console */
import nodemon from 'nodemon';

nodemon({
  args: process.argv.slice(2),
  exec: 'npm run -s test --',
  ext: 'js',
  watch: ['src/', 'test/'],
});

nodemon.on('start', () => {
  console.log('Test have started');
}).on('quit', () => {
  console.log('Test have quit');
  process.exit();
}).on('restart', (files) => {
  console.log('Test restarted due to: ', files);
});
github open-intent-io / open-intent / bindings / nodejs / lib / project / project.js View on Github external
}
            nodemonOpts.nodeArgs.push(debugArg);
        }
        if (options.nodeArgs) {
            nodemonOpts.nodeArgs = nodemonOpts.nodeArgs.concat(options.nodeArgs.split(' '));
        }

        var nodemon = require('nodemon');

        // hack to enable proxyquire stub for testing...
        if (_.isFunction(nodemon)) {
            nodemon(nodemonOpts);
        } else {
            nodemon._init(nodemonOpts, cb);
        }
        nodemon.on('start', function () {
            console.log('  project will restart on model changes.');

            if (options.open) {
                setTimeout(function() {
                    open(directory, options, cb);
                }, 500);
            }
        }).on('restart', function (files) {
            console.log('Project restarted. Files changed: ' + files);
        }).on('quit', function () {
            process.exit(0);
        }).on('readable', function() { // the `readable` event indicates that data is ready to pick up
            this.stdout.pipe(process.stdout);
            this.stderr.pipe(process.stderr);
        });
    });
github clippedjs / clipped / presets / webpack-backend / clipped.config.js View on Github external
clipped => new Promise((resolve, reject) => {
        nodemon({
          // Main field in package.json or dist/index.js
          script: mainFile || clipped.config.main || path.join(clipped.config.dist, 'index.js'),
          ext: 'js json',
          ignore: ["test/*", "docs/*"]
        })

        nodemon.on('start', function () {
          console.log('> App has started')
        }).on('quit', function () {
          console.log('> App has quit')
          process.exit();
        }).on('restart', function (files) {
          console.log('> App restarted due to: ', files)
        })
      })
    ])
github abecms / abecms / dist / tasks / nodemon.js View on Github external
},
  env: {
    'NODE_ENV': 'development'
  },
  ignore: ['docs/*'],
  watch: ['src/cli/*', 'src/hooks/*', 'src/server/routes/*', 'src/server/helpers/*', 'src/server/middlewares/*', 'src/server/controllers/*', 'src/server/app.js', 'src/server/index.js', process.env.ROOT + '/plugins/**/**/*.js', process.env.ROOT + '/abe.json', process.env.ROOT + '/locales/*', process.env.ROOT + '/test/*', process.env.ROOT + '/hooks/**/*.js', process.env.ROOT + '/reference/**/*.json'],
  stdin: true,
  runOnChangeOnly: false,
  verbose: true,
  // 'stdout' refers to the default behaviour of a required nodemon's child,
  // but also includes stderr. If this is false, data is still dispatched via
  // nodemon.on('stdout/stderr')
  stdout: true
});

nodemon.on('start', function () {}).on('quit', function () {
  console.log(clc.green('Kill process nodemon'));
  process.exit();
}).on('restart', function (files) {
  console.log('------------------------------------------------------------');
  console.log(clc.green('App restarted due to: '), files[0]);
});
github justinsisley / Invisible-Framework / tasks / startDev.js View on Github external
const start = () => {
  nodemon({
    script: serverIndex,
    watch: ['server/'],
    exec: 'node --inspect',
  });

  nodemon
  .on('quit', () => {
    process.exit(0);
  })
  .on('restart', (files) => {
    const fileList = files.map((file) => {
      const shortPath = file.replace(cwd, '');
      return `\n${shortPath}`;
    });

    // eslint-disable-next-line
    console.log(`\nApp restarted due to change in:${fileList}\n`);
  });
};
github swagger-api / swagger-node / lib / commands / project / project.js View on Github external
}
    // https://www.npmjs.com/package/cors
    nodemonOpts.env = {
      swagger_corsOptions: '{}' // enable CORS so editor "try it" function can work
    };
    if (options.mock) {
      nodemonOpts.env.swagger_mockMode = true
    }
    var nodemon = require('nodemon');
    // hack to enable proxyquire stub for testing...
    if (_.isFunction(nodemon)) {
      nodemon(nodemonOpts);
    } else {
      nodemon._init(nodemonOpts, cb);
    }
    nodemon.on('start', function () {
      emit('  project started here: ' + project.api.localUrl);
      emit('  project will restart on changes.');
      emit('  to restart at any time, enter `rs`');

      if (options.open) {
        setTimeout(function() {
          open(directory, options, cb);
        }, 500);
      }
    }).on('restart', function (files) {
      emit('Project restarted. Files changed: ', files);
    }).on('quit', function () {
      process.exit(0);
    });
  });
}
github denali-js / core / lib / cli / server.js View on Github external
DENALI_ENV: program.environment,
    PORT: program.port
  }, env);
  env = filter(env, not(isEmpty));

  nodemon({
    script: serverPath,
    ignore: [ 'node_modules\/(?!denali)', 'node_modules/denali/node_modules' ],
    debug: program.debug,
    env: env
  });

  nodemon.on('quit', function() {
    console.log('Goodbye!');
  });
  nodemon.on('restart', function(files) {
    console.log(`\nFiles changed:\n  ${ files.join('\n  ') }\nrestarting ...\n`);
  });
  nodemon.on('crash', function() {
    console.log(chalk.red.bold(`Server crashed! Waiting for file changes to restart ...`));
  });

} else {

  let spawnOptions = {
    stdio: 'inherit',
    env: assign({
      DENALI_ENV: program.environment,
      PORT: program.port
    }, process.env)
  };
github adonisjs / adonis-cli / src / Commands / Serve / index.js View on Github external
execMap: {
        js: execJsCommand
      },
      ext: ext,
      legacyWatch: !!polling,
      ignore: ['/tmp/*', '/resources/*', '/public/*'].concat(ignore || []).map((folder) => `${process.cwd()}/${folder}`),
      watch: watchDirs,
      stdin: false
    })

    this.started(dev, debug)

    /**
     * Listeners
     */
    nodemon
      .on('restart', this.onRestart.bind(this))
      .on('crash', this.onCrash.bind(this))
      .on('quit', () => (this.onQuit()))
  }
}
github atSistemas / angular-base / server / bootstrap / index.js View on Github external
"node_modules/**/node_modules"
        ],
        "verbose": true,
        "execMap": {
            "js": "node"
        },
        "watch": [
            "server/**/*.*"
        ],
        "env": {
            "NODE_ENV": "development"
        },
        "ext": "js ts json"
    });

    nodemon.on('start', function () {

    }).on('quit', function () {
        base.console.info("Development server has exited");
    }).on('restart', function (files) {
        console.log(base.console.symbols.CR);
        base.console.info('Restarting server due to changes on the following files:' + base.console.symbols.CR);
        if (Array.isArray(files)) {
            files.forEach((file) => console.log(`    ${file}`));
        } else {
            console.log(`    ${files}`);
        }
        console.log(base.console.symbols.CR);
    });

    config = nodemon.config;
} else {

nodemon

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

MIT
Latest version published 3 months ago

Package Health Score

97 / 100
Full package analysis