Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemon

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemon - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

coverage/coverage.json

1

bin/nodemon.js

@@ -15,4 +15,3 @@ #!/usr/bin/env node

var options = cli.parse(process.argv);
options.restartable = 'rs';
nodemon(options);
// default options for config.options
module.exports = {
restartable: 'rs',
execMap: {

@@ -10,6 +11,6 @@ py: 'python',

},
watch: [],
ignore: ['.git', 'node_modules/**/node_modules'],
ignore: ['.git/', 'node_modules/**/node_modules/'],
watch: ['*.*'],
stdin: true,
verbose: false
};

@@ -25,7 +25,12 @@ 'use strict';

scriptExt = path.extname(script),
extension = options.ext || scriptExt || '.js';
extension = options.ext || scriptExt || 'js';
// strip any leading periods int he extension
if (extension.indexOf('.') === 0) {
extension = extension.slice(1);
}
// allows the user to simplify cli usage: https://github.com/remy/nodemon/issues/195
if (execMap[extension.slice(1)] !== undefined) {
options.exec = execMap[extension.slice(1)];
if (execMap[extension] !== undefined) {
options.exec = execMap[extension];
}

@@ -75,3 +80,3 @@

if (!options.ext) {
extension = '.coffee|.litcoffee|.js';
extension = 'coffee litcoffee js';
}

@@ -99,4 +104,4 @@

.map(function (item) {
return '.' + item.replace(/^[\*\.]+/, ''); // remove "*."
}).join('$|'); // return regexp string like: .js$|.jade$
return item.replace(/^[\*\.]+/, ''); // remove "*."
}).join(','); // return regexp string like: .js$|.jade$
}

@@ -106,3 +111,3 @@

// single extensions work
extension += '$';
// extension += '$';

@@ -109,0 +114,0 @@ options.ext = extension;

@@ -9,7 +9,7 @@ 'use strict';

var load = require('./load'),
bus = require('../utils/bus'),
rules = require('../rules'),
utils = require('../utils'),
fs = require('fs'),
path = require('path'),
existsSync = fs.existsSync || path.existsSync,
bus = utils.bus,
checkWatchSupport = require('./checkWatchSupport');

@@ -21,5 +21,3 @@

config.dirs = [];
config.ignoring = [];
config.watch = [];
config.options = {};
config.options = { ignore: [], watch: [] };
config.lastStarted = 0;

@@ -30,2 +28,3 @@ config.loaded = [];

var config = {
run: false,
system: {

@@ -37,3 +36,2 @@ noWatch: false,

dirs: [],
ignoring: [],
timeout: 1000,

@@ -58,18 +56,55 @@ options: {}

if (options.execOptions.ext) {
rules.watch.add(new RegExp(options.execOptions.ext));
if (options.watch && options.watch.length) {
options.monitor = utils.clone(options.watch);
}
// read directories to monitor
options.watch.forEach(function (dir) {
dir = path.resolve(dir);
if (existsSync(config.dir)) {
config.dirs.push(path.resolve(config.dir));
}
});
if (options.ignore) {
[].push.apply(options.monitor, (options.ignore || []).map(function (rule) {
return '!' + rule;
}));
}
// if (options.execOptions.ext) {
// options.execOptions.ext.split(',').forEach(function (ext) {
// options.monitor.push(ext);
// });
// }
// delete options.watch;
// delete options.ignore;
var cwd = process.cwd();
if (config.dirs.length === 0) {
config.dirs.unshift(process.cwd());
config.dirs.unshift(cwd);
}
// next check if the monitored paths are actual directories
// or just patterns - and expand the rule to include *.*
options.monitor = options.monitor.map(function (rule) {
var not = rule.slice(0, 1) === '!';
if (rule.slice(-1) === '/') {
// just slap on a * anyway
return rule + '*';
}
if (not) {
rule = rule.slice(1);
}
var dir = path.resolve(cwd, rule);
try {
var stat = fs.statSync(dir);
if (stat.isDirectory()) {
if (rule.slice(-1) !== '/') {
rule += '/';
}
rule += '*';
}
} catch (e) {}
return (not ? '!' : '') + rule;
});
// now run automatic checks on system adding to the config object

@@ -76,0 +111,0 @@ checkWatchSupport(config, function (config) {

@@ -63,3 +63,3 @@ 'use strict';

// then try loading an old style .nodemonignore file
if (config.loaded.length === 0 && options.ignore.length === 0) {
if (config.loaded.length === 0) {
// TODO decide whether this is just confusing...

@@ -66,0 +66,0 @@ var legacy = loadLegacyIgnore.bind(null, options, ready);

@@ -91,2 +91,9 @@ 'use strict';

if (child !== null) {
// if the stdin piping is on, we need to unpipe, but also close stdin on
// the child, otherwise linux can throw EPIPE or ECONNRESET errors.
if (options.stdin) {
process.stdin.unpipe(child.stdin);
child.stdin.end();
}
// When using CoffeeScript under Windows, child's process is not node.exe

@@ -115,3 +122,3 @@ // Instead coffee.cmd is launched, which launches cmd.exe, which starts

// pinched from https://github.com/DTrejo/run.js - pipes stdin to the child process - cheers DTrejo ;-)
// connect stdin to the child process (options.stdin is on by default)
if (options.stdin) {

@@ -124,3 +131,2 @@ process.stdin.resume();

watch();
// setTimeout(watch, timeout);
}

@@ -168,2 +174,10 @@

// if we're not running already, don't bother with trying to kill
if (config.run === false) {
return exit();
}
// immediately try to stop any polling
config.run = false;
if (child) {

@@ -173,4 +187,7 @@ child.removeAllListeners('exit');

child.kill('SIGINT');
// give up waiting for the kids after 10 seconds
setTimeout(exit, 10 * 1000);
} else {
exit();
}
setTimeout(exit, 10 * 1000); // give up waiting for the kids after 10 seconds
});

@@ -177,0 +194,0 @@

@@ -7,2 +7,3 @@ 'use strict';

bus = utils.bus,
match = require('./match'),
config = require('../config'),

@@ -126,25 +127,19 @@ childProcess = require('child_process'),

function filterAndRestart(files) {
var data = {};
if (files.length) {
data.all = files.length;
utils.log.detail('files triggering change check: ' + files.join('\n'));
var cwd = process.cwd();
utils.log.detail('files triggering change check: ' + files.map(function (file) {
return path.relative(cwd, file);
}).join(', '));
files = files.filter(ignoredFilter);
data.ignore = files.length;
if (config.options.watch.length) {
files = files.filter(function (file) {
return config.options.watch.re && config.options.watch.re.test(file);
});
if (!config.options.execOptions) {
console.log(config);
}
var matched = match(files, config.options.monitor, config.options.execOptions.ext);
data.watch = files.length;
utils.log.detail('changes after filters (before/after): ' + [files.length, matched.result.length].join('/'));
utils.log.detail('changes after filters (pre/ignored/valid): ' + [data.all, data.ignore, data.watch].join('/'));
// reset the last check so we're only looking at recently modified files
config.lastStarted = Date.now();
if (files.length) {
if (matched.result.length) {
if (restartTimer !== null) {

@@ -155,3 +150,3 @@ clearTimeout(restartTimer);

utils.log.status('restarting due to changes...');
files.forEach(function (file) {
matched.result.forEach(function (file) {
utils.log.detail(path.relative(process.cwd(), file));

@@ -171,7 +166,9 @@ });

if (config.system.noWatch || config.options.forceLegacyWatch) {
setTimeout(monitor, config.timeout);
if (config.run) {
setTimeout(watch, config.timeout);
}
}
}
var monitor = module.exports = function () {
var watch = module.exports = function () {
// if we have noWatch or watchWorks (i.e. not using `find`)

@@ -181,3 +178,5 @@ // then called `changeFunction` which is local to this script

changeFunction(config.lastStarted, function (files) {
filterAndRestart(files);
if (config.run) {
filterAndRestart(files);
}
});

@@ -188,5 +187,7 @@ } else {

changedSince(config.lastStarted, function (files) {
filterAndRestart(files);
if (config.run) {
filterAndRestart(files);
}
});
}
};

@@ -7,2 +7,3 @@ 'use strict';

utils = require('./utils'),
rules = require('./rules'),
bus = utils.bus,

@@ -43,6 +44,14 @@ help = require('./help'),

// always echo out the current version
utils.log.info(version);
config.load(settings, function (config) {
if (!config.options.script) {
if (!config.required) {
console.log(help('usage'));
process.exit();
}
return;
}
config.load(settings, function (config) {
// always echo out the current version
utils.log.info(version);
// echo out notices about running state

@@ -92,11 +101,16 @@ if (config.options.restartable) {

config.dirs.forEach(function (dir) {
utils.log.info('watching: ' + dir);
});
var none = function (v) {
return v;
};
utils.log.detail('ignoring: ' + config.options.monitor.map(function (rule) {
return rule.slice(0, 1) === '!' ? rule.slice(1) : false;
}).filter(none).join(' '));
utils.log.info('watching: ' + config.options.monitor.map(function (rule) {
return rule.slice(0, 1) !== '!' ? rule : false;
}).filter(none).join(' '));
utils.log.detail('watching extensions: ' + config.options.ext);
config.options.ignore.forEach(function (pattern) {
utils.log.detail('ignoring: ' + pattern);
});

@@ -118,2 +132,3 @@ if (config.options.dump) {

config.run = true;
monitor.run(config.options);

@@ -142,3 +157,3 @@ });

bus.once(event, function () {
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 0);
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 1);
handler.apply(this, arguments);

@@ -161,3 +176,3 @@ });

bus.removeListener(event, handler);
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 0);
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 1);
});

@@ -171,4 +186,7 @@ // delete eventHandlers[event];

nodemon.reset = function () {
// console.trace();
nodemon.removeAllListners();
utils.reset();
rules.reset();
config.run = false;
};

@@ -181,14 +199,15 @@

// on exception *inside* nodemon, shutdown wrapped node app
if (!config.required) process.on('uncaughtException', function (err) {
console.error('exception in nodemon killing node');
console.error(err.stack);
console.error();
console.error('If appropriate, please file an error: http://github.com/remy/nodemon/issues/new\n');
if (!config.required) {
process.exit(1);
}
});
if (!config.required) {
process.on('uncaughtException', function (err) {
console.error('exception in nodemon killing node');
console.error(err.stack);
console.error();
console.error('If appropriate, please file an error: http://github.com/remy/nodemon/issues/new\n');
if (!config.required) {
process.exit(1);
}
});
}
module.exports = nodemon;

@@ -0,1 +1,5 @@

'use strict';
var utils = require('../utils');
// internal

@@ -42,3 +46,5 @@ var reEscComments = /\\#/g,

if (rule instanceof RegExp) {
rule = ':' + rule.toString().replace(/^\/(.*?)\/$/g, '$1');
// rule = ':' + rule.toString().replace(/^\/(.*?)\/$/g, '$1');
utils.log.error('RegExp format no longer supported, but globs are.');
return;
}

@@ -58,2 +64,3 @@

rule = rule.substring(1);
utils.log.error('RegExp no longer supported: ' + rule);
regexp = true;

@@ -66,12 +73,17 @@ } else if (rule.length === 0) {

if (regexp) {
rules[which].push(rule);
// rules[which].push(rule);
} else {
rule = rule.replace(reEscapeChars, '\\$&')
.replace(reAsterisk, '.*');
// rule = rule.replace(reEscapeChars, '\\$&')
// .replace(reAsterisk, '.*');
rules[which].push(rule);
// compile a regexp of all the rules for this ignore or watch
var re = rules[which].map(function (rule) {
return rule.replace(reEscapeChars, '\\$&')
.replace(reAsterisk, '.*');
}).join('|');
// used for the directory matching
rules[which].re = new RegExp(re);
}
// compile a regexp of all the rules for this ignore or watch
rules[which].re = new RegExp(rules[which].join('|'));
}

@@ -39,2 +39,4 @@ 'use strict';

rules.ignore.length = rules.watch.length = 0;
delete rules.ignore.re;
delete rules.watch.re;
},

@@ -41,0 +43,0 @@ load: load,

@@ -0,1 +1,2 @@

'use strict';
var events = require('events'),

@@ -2,0 +3,0 @@ util = require('util');

@@ -25,3 +25,3 @@ 'use strict';

Object.keys(this.log).forEach(function (method) {
// this.log[method] = noop;
this.log[method] = noop;
}.bind(this));

@@ -33,6 +33,9 @@ }

Object.keys(this.log).forEach(function (method) {
// delete this.log[method];
delete this.log[method];
}.bind(this));
}
this.debug = false;
},
regexpToText: function (t) {
return t.replace(/\.\*\\./g, '*.').replace(/\\{2}/g, '^^').replace(/\\/g, '').replace(/\^\^/g, '\\');
}

@@ -39,0 +42,0 @@ };

@@ -54,3 +54,3 @@ 'use strict';

if (required) {
bus.emit('log', { type: type, message: msg, colour: msg });
bus.emit('log', { type: type, message: msg || '', colour: msg || '' });
} else if (type === 'error') {

@@ -57,0 +57,0 @@ util.error(msg);

@@ -24,3 +24,3 @@ {

],
"version": "1.0.2",
"version": "1.0.3",
"preferGlobal": "true",

@@ -35,4 +35,4 @@ "licenses": [

"scripts": {
"coverage": "istanbul cover _mocha -- --timeout 15000 --ui bdd --reporter list test/**/*.test.js",
"test": "node_modules/mocha/bin/_mocha --timeout 15000 --ui bdd --reporter list test/**/*.test.js",
"coverage": "istanbul cover _mocha -- --timeout 20000 --ui bdd --reporter list test/**/*.test.js",
"test": "node_modules/mocha/bin/_mocha --timeout 20000 --ui bdd test/**/*.test.js",
"web": "node web"

@@ -48,4 +48,5 @@ },

"dependencies": {
"update-notifier": "~0.1.7"
"update-notifier": "~0.1.7",
"minimatch": "~0.2.14"
}
}

@@ -0,3 +1,7 @@

![nodemon logo](http://nodemon.io/nodemon.png)
# nodemon
[![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1211372/remynodemon-on-GitHub)
For use during development of a node.js based application.

@@ -9,2 +13,5 @@

[![NPM version](https://badge.fury.io/js/nodemon.png)](http://badge.fury.io/js/nodemon)
[![Travis Status](https://travis-ci.org/remy/nodemon.png)](https://travis-ci.org/remy/nodemon)
# Installation

@@ -79,2 +86,6 @@

## Using nodemon as a module
Please see [doc/requireable.md](doc/requireable.md)
## Running non-node scripts

@@ -81,0 +92,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc