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

nodemon

Package Overview
Dependencies
Maintainers
0
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 0.4.1 to 0.5.0

78

nodemon.js

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

oldIgnoreFilePath = './nodemon-ignore',
ignoreFiles = [flag, ignoreFilePath], // ignore the monitor flag by default
ignoreFiles = [],
reIgnoreFiles = null,

@@ -34,2 +34,3 @@ timeout = 1000, // check every 1 second

var ext = path.extname(app);
if (ext === '.coffee') {

@@ -62,3 +63,3 @@ node = spawn('coffee', nodeArgs);

function startMonitor() {
var cmd = 'find . -type f -newer ' + flag + ' -print';
var cmd = 'find -L . -type f -newer ' + flag + ' -print';

@@ -102,2 +103,16 @@ exec(cmd, function (error, stdout, stderr) {

function addIgnoreRule(line, noEscape) {
// remove comments and trim lines
// this mess of replace methods is escaping "\#" to allow for emacs temp files
if (!noEscape) {
if (line = line.replace(reEscComments, '^^').replace(reComments, '').replace(reUnescapeComments, '#').replace(reTrim, '')) {
ignoreFiles.push(line.replace(reEscapeChars, '\\$&').replace(reAsterisk, '.*'));
}
} else {
ignoreFiles.push(line);
}
reIgnoreFiles = new RegExp(ignoreFiles.join('|'));
}
function readIgnoreFile() {

@@ -108,23 +123,17 @@ fs.unwatchFile(ignoreFilePath);

path.exists(ignoreFilePath, function(exists) {
if (!exists) {
// if (!exists) {
// we'll touch the ignore file to make sure it gets created and
// if Vim is writing the file, it'll just overwrite it - but also
// prevent from constant file io if the file doesn't exist
fs.writeFileSync(ignoreFilePath, "\n");
setTimeout(readIgnoreFile, 500);
return;
}
// fs.writeFileSync(ignoreFilePath, "\n");
// setTimeout(readIgnoreFile, 500);
// return;
// }
sys.log('[nodemon] reading ignore list');
ignoreFiles = [flag, ignoreFilePath];
fs.readFileSync(ignoreFilePath).toString().split(/\n/).forEach(function (line) {
// remove comments and trim lines
// this mess of replace methods is escaping "\#" to allow for emacs temp files
if (line = line.replace(reEscComments, '^^').replace(reComments, '').replace(reUnescapeComments, '#').replace(reTrim, '')) {
ignoreFiles.push(line.replace(reEscapeChars, '\\$&').replace(reAsterisk, '.*'));
}
});
reIgnoreFiles = new RegExp(ignoreFiles.join('|'));
// ignoreFiles = ignoreFiles.concat([flag, ignoreFilePath]);
addIgnoreRule(flag);
addIgnoreRule(ignoreFilePath);
fs.readFileSync(ignoreFilePath).toString().split(/\n/).forEach(addIgnoreRule);

@@ -136,3 +145,18 @@ fs.watchFile(ignoreFilePath, { persistent: false }, readIgnoreFile);

function usage() {
sys.print('usage: nodemon [--debug] [your node app]\ne.g.: nodemon ./server.js localhost 8080\nFor details see http://github.com/remy/nodemon/\n\n');
sys.print([
'usage: nodemon [options] [script.js] [args]',
'e.g.: nodemon script.js localhost 8080',
'',
'Options:',
' --js monitor only JavaScript file changes',
' (default if ignore file not found)',
' -d n, --delay n throttle restart for "n" seconds',
' --debug enable node\'s native debug port',
' -v, --version current nodemon version',
' -h, --help this usage',
'',
'Note: if the script is omitted, nodemon will try "main" from package.json',
'',
'For more details see http://github.com/remy/nodemon/\n'
].join('\n'));
}

@@ -145,3 +169,3 @@

fn(nodeArgs[i], i);
} else if ((i = nodeArgs.indexOf('-' + label.substr(1))) !== -1) {
} else if ((i = nodeArgs.indexOf('-' + label.substr(0, 1))) !== -1) {
fn(nodeArgs[i], i);

@@ -181,2 +205,9 @@ } else if ((i = nodeArgs.indexOf('--' + label)) !== -1) {

controlArg(nodeArgs, 'js', function (arg, i) {
nodeArgs.splice(i, 1); // remove this flag from the arguments
// sys.log('[nodemon] monitoring all filetype changes');
addIgnoreRule('^((?!\.js$).)*$', true); // ignores everything except JS
app = nodeArgs[0];
});
controlArg(nodeArgs, '--debug', function (arg, i) {

@@ -210,4 +241,4 @@ nodeArgs.splice(i, 1);

// Change to application dir
process.chdir(path.dirname(app));
// this was causing problems for a lot of people, so now not moving to the subdirectory
// process.chdir(path.dirname(app));
app = path.basename(app);

@@ -227,4 +258,7 @@ sys.log('[nodemon] running ' + app + ' in ' + process.cwd());

ignoreFilePath = oldIgnoreFilePath;
} else {
// don't create the ignorefile, just ignore the flag & JS
addIgnoreRule(flag);
addIgnoreRule('^((?!\.js$).)*$', true);
}
readIgnoreFile();
});

@@ -231,0 +265,0 @@ } else {

@@ -12,5 +12,5 @@ {

"keywords": ["monitor", "development", "restart", "autoload", "reload", "terminal"],
"version": "0.4.1",
"version": "0.5.0",
"preferGlobal" : "true",
"main": "./nodemon"
}

@@ -53,8 +53,6 @@ # nodemon

In some cases you will want to ignore some specific files, directories or file patterns, to prevent `nodemon` from prematurely restarting your application.
By default, if `nodemon` will only restart when a `.js` JavaScript file changes. In some cases you will want to ignore some specific files, directories or file patterns, to prevent `nodemon` from prematurely restarting your application.
The `.nodemonignore` file is automatically created in the directory that you run your application from, so that you can have application specific ignore lists.
You can use the [example ignore file](http://github.com/remy/nodemon/blob/master/nodemonignore.example) (note that this example file is not hidden - you must rename it to `.nodemonignore`) as a basis for your `nodemon`, but it's very simple to create your own:
You can use the [example ignore file](http://github.com/remy/nodemon/blob/master/nodemonignore.example) as a basis for your `nodemon`, but it's very simple to create your own:
# this is my ignore file with a nice comment at the top

@@ -61,0 +59,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