'use strict'; if (process.env.NODE_ENV === 'development') { const nodemon = require('nodemon'); nodemon({ script: 'src/server/start.js', watch: 'src/server/' }); } else { require('./server/start'); }
webpack(buildConfig, (err, stats) => { const prefix = ['webpack build'] if (err) { console.log(`${prefix} error`, err) } console.log(`${prefix}`, stats.toString({ colors: true })) }) */ // start node server, and restart it on file change const demon = nodemon({ script: path.join(__dirname, 'src', 'server.js'), watch: path.join(__dirname, 'src', 'server.js') }).on('start', () => { console.log('node server has started') bs.reload() }).on('exit', () => { console.log('node server has exited') }) process.on('exit', () => { demon.emit('exit') })
gulp.task('start:server:prod', () => { process.env.NODE_ENV = process.env.NODE_ENV || 'production'; config = require(`./${paths.dist}/${serverPath}/config/environment`); nodemon(`-w ${paths.dist}/${serverPath} ${paths.dist}/${serverPath}`) .on('log', onServerLog); });
module.exports = function(args){ var pkg = require(cwd + '/package.json'); var commandOpts = pkg.main + ' ' + process.argv.slice(3).join(' '); nodemon(commandOpts); };
process.env.NODE_ENV = 'development'; var nodemon = require('nodemon'); nodemon('--exec babel-node --presets=es2015 ./src/main.js --watch ./src'); nodemon.on('start', function() { console.log('[nodemon] App has started'); }).on('quit', function() { console.log('[nodemon] App has quit'); }).on('restart', function(files) { console.log('[nodemon] App restarted due to:', files); });
/* eslint-disable no-console */ import Nodemon from 'nodemon'; Nodemon({ args: process.argv, script: 'test/unit.js', execMap: {js: 'node_modules/.bin/babel-node'}, ext: 'js', watch: 'src/', }); Nodemon.on('start', () => { console.log('Unit tests have started'); }).on('quit', () => { console.log('Unit tests have quit'); process.exit(); }).on('restart', (files) => { console.log('Unit tests restarted due to: ', files); });
'use strict'; // Run this to auto-reload the server on file changes. var nodemon = require('nodemon'); nodemon({ script: 'webtls.js', ext: 'js json', "execMap": { "js": "node --harmony" }, "ignore": [ ".git", "client/**", "**/*.spec.js" ] });
gulp.task('node-server', function () { nodemon({ script: './server/start.js', env: { 'NODE_ENV': 'production' } }); });
gulp.task('node-server:dev', function () { nodemon({ script: './server/start.js', env: { 'NODE_ENV': 'development' } }); });
// console.log("filepaths",filepaths); for (var j = 0; j < config.watch[i].dirs.length; j++) { var p = config.watch[i].dirs[j]; p = p.replace("/**", ""); p = p.replace("/*", ""); watch.push(p); } } } nodemon({ script: "prod.js", ext: "js json", // args: ['ENV=development', 'PORT=5000'], env: { ENV: "development" // PORT: 8000 }, // ignore: [".tmp/**", "assets/**", "views/**"], // verbose: true, watch: watch }); nodemon .on("start", () => { console.warn(chalk.green("!!!!App has started in development mode")); // console.log("nodemon.config",nodemon.config); }) .on("quit", () => { console.warn(chalk.gray("!!!!App has quit")); }) .on("restart", files => {
gulp.task('start', function () { nodemon({ script: 'server.js' }); });
'use strict'; require('dotenv').load(); const webpack = require('webpack'); const merge = require('webpack-merge'); const nodemon = require('nodemon'); const nodemonConfig = require('../nodemon.json'); const mergeCommon = merge.bind(null, require('./webpack.common')); nodemon(nodemonConfig); module.exports = mergeCommon({ devtool: 'eval-source-map', devServer: { historyApiFallback: true, hot: true, inline: true, progress: true, host: process.env.HOST, port: process.env.DEV_PORT, proxy: { '/api/*': 'http://' + process.env.HOST + ':' + process.env.PORT } }, plugins: [
var nodemon = require('nodemon'); nodemon({ script: 'server.js', ext: 'js json' }); nodemon.on('start', function () { console.log('App has started'); }).on('quit', function () { console.log('App has quit'); }).on('restart', function (files) { console.log('App restarted due to: ', files); });
return new Promise((resolve, reject) => { const runner = nodemon({ script: path.resolve(__dirname, '../..', 'server/localhost.js'), stdout: false, ext: 'js json ts', watch: [ project.resolvePath('src/server'), project.resolvePath('src/common'), ], nodeArgs: [ // ad-hoc debugging (doesn't allow debugging of bootstrap, but app will run with debugger // off) '--debug=5858', // explicit debugging (app won't start until remote debugger connects) // '--debug-brk=5858', '--expose_debug_as=v8debug', //required for webstorm due to // https://youtrack.jetbrains.com/issue/WEB-21717 ], env: { 'NODE_ENV': 'development', 'NODEMON_ENTRYPOINT': project.resolvePath('./dist/server/server/main.js'), 'FORCE_COLOR': true, // force chalk to detect that colour is supported (it is!) 'SERVER_ONLY': serverOnly // only watch the server (skip webpack dev server) }, verbose: true }); runner.on('change', () => { build(project, cli); }); runner.on('exit', function () { cli.log('Watcher has quit'); }); // Forward log messages and stdin runner.on('log', (log) => { if (~log.message.indexOf('files triggering change check')) { runner.emit('change'); } cli.log(chalk.blue('[nodemon]'), chalk.yellow(log.message)); }); runner.on('readable', function () { this.stdout.on('data', (chunk) => { let log = chunk.toString(); if (_.includes(log, 'bundle is now VALID') || serverOnly && _.includes(log, 'Server running at:')) { cli.log('Returning control to user'); resolve(runner); } cli.log(chalk.green('[server]'), log); }); this.stderr.on('data', (chunk) => { let log = chunk.toString(); cli.log(chalk.red('[server]'), log); }); }); });
module.exports = function (options) { options = options || {}; if (options.exec instanceof Array) options.exec = options.exec.join(' ') if (typeof options.exec === 'string') options.exec = 'gulp ' + options.exec if (typeof options.tasks === 'function') options.verbose = true // Enable verbose mode if file change list is needed // Our script var script = nodemon(options) , originalOn = script.on // Allow for injection of tasks on file change if (options.tasks) { if (options.verbose) { script.on('log', function (log) { if (~log.message.indexOf('files triggering change check')) { if (typeof options.tasks === 'function') run(options.tasks(log.message.split('files triggering change check: ').pop().split(' '))) else run(options.tasks) } }) } else { script.on('log', function (log) { if (~log.message.indexOf('restarting due to changes...')) { run(options.tasks) } }) } } // Capture ^C process.on('exit', script.emit.bind(script, 'exit')) // Forward log messages and stdin script.on('log', function (log) { console.log('[' + new Date().toString().split(' ')[4].gray + '] ' + ('[nodemon] ' + log.message).yellow) }) // Shim 'on' for use with gulp tasks script.on = function (event, tasks) { var tasks = Array.prototype.slice.call(arguments) , event = tasks.shift() if (event === 'change') script.changeTasks = tasks else { for (var i = 0; i < tasks.length; i++) { void function (tasks) { if (tasks instanceof Function) originalOn(event, tasks) else { originalOn(event, function () { if (Array.isArray(tasks)) { tasks.forEach(function (task) { run(task) }) } else run(tasks) }) } }(tasks[i]) } } return script } return script // Synchronous alternative to gulp.run() function run(tasks) { if (typeof tasks === 'string') tasks = [tasks] if (!(tasks instanceof Array)) throw new Error('Expected task name or array but found: ' + tasks) cp.spawnSync('gulp', tasks, { stdio: [0, 1, 2] }) } }
module.exports = function(projectPath, options) { let Botpress = null if (!projectPath || typeof projectPath !== 'string') { projectPath = '.' } projectPath = path.resolve(projectPath) try { // eslint-disable-next-line no-eval Botpress = eval('require')(path.join(projectPath, 'node_modules', 'botpress')).Botpress() } catch (err) { util.print('error', err.message) util.print('error', err.stack) util.print('error', '(fatal) Could not load the local version of botpress') util.print('Hint: 1) have you used `botpress init` to create a new bot the proper way?') util.print('Hint: 2) Do you have read and write permissions on the current directory?') util.print('-------------') util.print( 'If none of the above works, this might be a bug in botpress. ' + 'Please contact the Botpress Team on gitter and provide the printed error above.' ) process.exit(1) } const botfile = path.join(projectPath, 'botfile.js') if (!fs.existsSync(botfile)) { util.print('error', `(fatal) No ${chalk.bold('botfile.js')} file found at: ` + botfile) process.exit(1) } const getDefaultWatchIgnore = () => { // eslint-disable-next-line no-eval const bf = eval('require')(botfile) const dataDir = util.getDataLocation(bf.dataDir, projectPath) const modulesConfigDir = util.getDataLocation(bf.modulesConfigDir, projectPath) return [dataDir, modulesConfigDir, 'node_modules'] } const opts = options.opts() if (opts.watch || opts.w) { util.print('info', '*** watching files for changes ***') const argvWithoutWatch = process.argv.filter(arg => !/^(--watch|-w)$/.test(arg)) argvWithoutWatch[0] = getPath(argvWithoutWatch[0]) const nodemonOptions = { cwd: process.cwd(), exec: argvWithoutWatch.join(' '), ext: opts.watchExt, watch: opts.watchDir && opts.watchDir.length ? opts.watchDir : undefined, ignore: opts.watchIgnore && opts.watchIgnore.length ? opts.watchIgnore : getDefaultWatchIgnore(), stdin: false, restartable: false } const mon = nodemon(nodemonOptions) mon.on('restart', (changedFile, two) => util.print('info', '*** restarting botpress because of file change: ', changedFile) ) monitorCtrlC(() => { mon.emit('quit') setTimeout(() => process.exit(), 100) }) } else { const bot = new Botpress({ botfile }) bot.start() } }
gulp.task('startServer', function() { nodemon({script: "index.js", "ignore": ["./public"]}) .on("start", () => {console.log("server started");}); });
var nodemon = require('nodemon'); nodemon({ script: 'bin/www', ext: 'js json' }); nodemon.on('start', function() { console.log('App has started'); }).on('quit', function() { console.log('App has quit'); }).on('restart', function(files) { console.log('App restarted due to: ', files); });
var logger = require('./logger') var nodemon = require('nodemon'); var ignore = [ projectRoot + "/public", projectRoot + "/.git", projectRoot + '/client', __dirname + '/../scss', __dirname + '/../client' ]; nodemon({ script: __dirname + '/cli.js', ext: 'js json coffee jsx cjsx', watch: ['*.*', Path.resolve(__dirname, '..')], ignore: ignore, env: { NODE_ENV: "development" } }); logger.info('Starting the server in DEVELOPMENT mode'); nodemon.on('start', function () { // logger.info('App has started'); }).on('restart', function (files) { logger.info('The server restarted due to: ', files) }); } else { module.exports = {
weinre: { port: config.get('browserSync.weinrePort') } }, files: ['public/**'], server: false, proxy: config.get('web.hostname') + ':' + config.get('web.port'), port: config.get('browserSync.port'), open: false, reloadDelay: 200 }); nodemon( { watch: ['src-server/**/*', 'config/*'], script: 'src-server/index.js', ext: 'js', stdout: false }) .on('readable', function () { this.stdout.on('data', function(chunk) { process.stdout.write(chunk); if (/^Web server started/.test(chunk)) { livereloadServer.refresh(nodemonChangedFiles[0]); // In case livereload doesn't work in your browser, uncomment below line // browserSync.reload(nodemonChangedFiles); console.log(`${livereloadLogPrefix} reload file ${nodemonChangedFiles[0]}`); } });
gulp.task('default', ['server-watch', 'client-watch'], () => { nodemon({ execMap: {js: 'node'}, script: path.join(__dirname, 'build/server'), }).on('restart', () => console.log('[nodemon] restart')); });
const path = require('path'); const nodemon = require('nodemon'); nodemon({ ext: 'js json', // --silent squashes an ELIFECYCLE error when the server exits exec: 'npm run --silent babel-dev-server', watch: path.resolve(__dirname, './server'), spawn: true, env: { DEBUG: 'fcc*' } }); nodemon.on('restart', function nodemonRestart(files) { console.log('App restarted due to: ', files); });
/* eslint-disable no-console */ import Nodemon from 'nodemon'; Nodemon({ args: process.argv, script: 'test/index.js', execMap: {js: 'node_modules/.bin/babel-node'}, ext: 'js', watch: ['src/', 'test/integration'], }); 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); });
#!/usr/bin/env node var nodemon = require('nodemon') const HORESE_DIR = __dirname; const DIR = process.cwd() nodemon({ script: HORESE_DIR+"/server_prod.js", exec: HORESE_DIR+"/node_modules/.bin/babel-node", ignoreRoot: DIR+"/src/" }) // module.exports = function(){ // nodemon({ // script: HORESE_DIR+"/server_prod.js", // exec: HORESE_DIR+"/node_modules/.bin/babel-node" // }) // } // ../../server.js --exec ../../node_modules/.bin/babel-node
const nodemon = require('nodemon'); const path = require('path'); nodemon({ execMap: { js: 'node' }, script: path.join(__dirname, 'server/server'), ignore: [], watch: process.env.NODE_ENV !== 'production' ? ['server/*'] : false, ext: 'js' }) .on('restart', function() { console.log('Server restarted!'); }) .once('exit', function () { console.log('Shutting down server'); process.exit(); });
gulp.task('nodemon', function(){ nodemon({ script: 'server.js', ext: 'js' }); });
gulp.task('nodemon', function () { nodemon({ script: 'src/index.js', ext: 'js', 'execMap': { 'h': '--harmony'} }); });
gulp.task('server', ['build'], function() { nodemon({ script: 'app.js', ext: 'js html' }); });
gulp.task('start:server', () => { process.env.NODE_ENV = process.env.NODE_ENV || 'development'; config = require(`./${serverPath}/config/environment`); nodemon(`-w ${serverPath} ${serverPath}`) .on('log', onServerLog); });
return new Promise((resolve, reject) => { nodemon({ exec: 'babel-node', script: path.join(__dirname, '../src/server.js'), }) nodemon.on('start', function () { console.log('[nodemon] Backend started.'); }).on('quit', function () { console.log('[nodemon] Backend stopped.'); }).on('restart', function (files) { console.log('[nodemon] Files changed, restarting.'); files.map((file) => { console.log(' -', file) }) }); webpackFrontendConfig.entry = [ webpackFrontendConfig.entry, 'webpack-hot-middleware/client' ] // Tune the output config for our dev middleware. The «path» part is really important, I don't // know if the hash/chunkhash part has any use. webpackFrontendConfig.output.path = path.join(webpackDefaultConfig.output.path, 'public') webpackFrontendConfig.output.filename = webpackFrontendConfig.output.filename.replace('[chunkhash]', '[hash]') webpackFrontendConfig.output.chunkFilename = webpackFrontendConfig.output.chunkFilename.replace('[chunkhash]', '[hash]') // Client side plugins for proxy-mode development webpackFrontendConfig.plugins = [ new webpack.HotModuleReplacementPlugin(), ...webpackFrontendConfig.plugins ] // Patch Webpack's babel loader(s) webpackFrontendConfig.module.loaders.filter(x => x.loader === 'babel-loader') .forEach((x) => { x.loaders = ['react-hot', x.loader + '?' + JSON.stringify(x.query || {})] delete x.loader delete x.query }); const bundler = webpack(webpackFrontendConfig); const webpackMiddleware = webpackDevMiddleware(bundler, { publicPath: webpackFrontendConfig.output.publicPath, stats: { colors: true } }) let browsersync = null; bundler.plugin('done', (err, stats) => { if (!browsersync) { browsersync = Browsersync.create(); browsersync.init({ ...(config.DEBUG ? {} : { notify: false, ui: false }), open: false, proxy: { target: 'localhost:3000', middleware: [ webpackMiddleware, webpackHotMiddleware(bundler), ] } }); } console.log('[webpack] State is now valid.') }); });