How to use nodemon - 10 common examples

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 tmeasday / create-graphql-server / test / output-app / index.js View on Github external
denodeify(mongoPrebuilt.start_server.bind(mongoPrebuilt))({
    auto_shutdown: true,
    args: {
      port: MONGO_PORT,
      dbpath,
    },
  })
  .catch((errorCode) => {
    const error = MONGO_CODES[errorCode];
    console.error(`Failed to start MongoDB server on port ${MONGO_PORT}`);
    console.error(`Error Code ${errorCode}: ${error ? error.longText : "Unknown"}`);
    process.exit(1);
  });
}

nodemon({
  script: path.join('server', 'index.js'),
  ext: 'js graphql',
  exec: 'babel-node',
}).on('restart', () => console.log('Restarting server due to file change\n'));


// Ensure stopping our parent process will properly kill nodemon's process
// Ala https://www.exratione.com/2013/05/die-child-process-die/

// SIGTERM AND SIGINT will trigger the exit event.
process.once("SIGTERM", function () {
  process.exit(0);
});
process.once("SIGINT", function () {
  process.exit(0);
});
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 staylor / graphql-wordpress / packages / draft-server / index.js View on Github external
import nodemon from 'nodemon';
import path from 'path';

/* eslint-disable no-console */

nodemon({
  script: path.join('server', 'index.js'),
  ext: 'js graphql',
  exec: 'babel-node',
}).on('restart', () => console.log('Restarting server due to file change\n'));

// Ensure stopping our parent process will properly kill nodemon's process
// Ala https://www.exratione.com/2013/05/die-child-process-die/

// SIGTERM AND SIGINT will trigger the exit event.
process.once('SIGTERM', () => {
  process.exit(0);
});
process.once('SIGINT', () => {
  process.exit(0);
});
// And the exit event shuts down the child.
github tmeasday / create-graphql-server / skel / index.js View on Github external
denodeify(mongoPrebuilt.start_server.bind(mongoPrebuilt))({
    auto_shutdown: true,
    args: {
      port: MONGO_PORT,
      dbpath,
    },
  })
  .catch((errorCode) => {
    const error = MONGO_CODES[errorCode];
    console.error(`Failed to start MongoDB server on port ${MONGO_PORT}`);
    console.error(`Error Code ${errorCode}: ${error ? error.longText : "Unknown"}`);
    process.exit(1);
  });
}

nodemon({
  script: path.join('server', 'index.js'),
  ext: 'js graphql',
  exec: 'babel-node',
}).on('restart', () => console.log('Restarting server due to file change\n'));


// Ensure stopping our parent process will properly kill nodemon's process
// Ala https://www.exratione.com/2013/05/die-child-process-die/

// SIGTERM AND SIGINT will trigger the exit event.
process.once("SIGTERM", function () {
  process.exit(0);
});
process.once("SIGINT", function () {
  process.exit(0);
});
github open-intent-io / open-intent / bindings / nodejs / lib / project / project.js View on Github external
if (typeof options.debug === 'string') {
                debugArg += '=' + options.debug;
            }
            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 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);
    });
  });
}

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