Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

The fix for issue #107 #108

Merged
merged 1 commit into from

3 participants

@vadimi

Also fixes issue with node restart on Windows after file change.

@vadimi vadimi Fix for issue #107
Also fixes issue with node restart on Windows after file change.
08e5aa1
@sberryman

Can you please pull this patch, it is really annoying having the process restart due to changes in the .git directory.

@remy remy merged commit 904b224 into from
@remy
Owner

Sorry, been busy on another project. Am bumping package version and pushing to npm momentarily.

@remy
Owner

v 0.6.22 (version jumped so much because it looked like npm was failing to publish, so I kept repeating command!)

@vadimi

Thanks!

@sberryman

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 7, 2012
  1. @vadimi

    Fix for issue #107

    vadimi authored
    Also fixes issue with node restart on Windows after file change.
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 33 deletions.
  1. +37 −33 nodemon.js
View
70 nodemon.js 100755 → 100644
@@ -143,14 +143,13 @@ watchFileChecker.check = function(cb) {
util.log('\x1B[32m[nodemon] Unable to write to temp directory. If you experience problems with file reloading, ensure ' + tmpdir + ' is writable.\x1B[0m');
cb(true);
return;
- }
- fs.writeSync(watchFile, '1');
+ }
fs.watch(watchFileName, function(event, filename) {
watchFileChecker.changeDetected = true;
cb(true);
});
-
// This should trigger fs.watch, if it works
+ fs.writeSync(watchFile, '1');
fs.unlinkSync(watchFileName);
setTimeout(function() { watchFileChecker.verify() }, 250);
@@ -301,21 +300,21 @@ function startMonitor() {
if ((noWatch || watchWorks) && !program.options.forceLegacyWatch) {
changeFunction(lastStarted, function (files) {
if (files.length) {
- if (restartTimer !== null) clearTimeout(restartTimer);
- restartTimer = setTimeout(function () {
- if (program.options.verbose) util.log('[nodemon] restarting due to changes...');
- files.forEach(function (file) {
- if (program.options.verbose) util.log('[nodemon] ' + file);
- });
- if (program.options.verbose) util.print('\n\n');
+ files = files.filter(ignoredFilter);
+ if (files.length) {
+ if (restartTimer !== null) clearTimeout(restartTimer);
+ restartTimer = setTimeout(function () {
+ if (program.options.verbose) util.log('[nodemon] restarting due to changes...');
+ files.forEach(function (file) {
+ if (program.options.verbose) util.log('[nodemon] ' + file);
+ });
+ if (program.options.verbose) util.print('\n\n');
- if (child !== null) {
- child.kill(isWindows ? '' : 'SIGUSR2');
- } else {
- startNode();
- }
- }, restartDelay);
- return;
+ killNode();
+
+ }, restartDelay);
+ return;
+ }
}
if (noWatch) setTimeout(startMonitor, timeout);
@@ -340,22 +339,8 @@ function startMonitor() {
});
if (program.options.verbose) util.print('\n\n');
- if (child !== null) {
- // When using CoffeeScript under Windows, child's process is not node.exe
- // Instead coffee.cmd is launched, which launches cmd.exe, which starts node.exe as a child process
- // child.kill() would only kill cmd.exe, not node.exe
- // Therefore we use the Windows taskkill utility to kill the process and all its children (/T for tree)
- if (isWindows) {
- // For the on('exit', ...) handler above the following looks like a crash, so we set the killedAfterChange flag
- killedAfterChange = true;
- // Force kill (/F) the whole child tree (/T) by PID (/PID 123)
- exec('taskkill /pid '+child.pid+' /T /F');
- } else {
- child.kill('SIGUSR2');
- }
- } else {
- startNode();
- }
+ killNode();
+
}, restartDelay);
return;
}
@@ -366,6 +351,25 @@ function startMonitor() {
}
}
+function killNode() {
+ if (child !== null) {
+ // When using CoffeeScript under Windows, child's process is not node.exe
+ // Instead coffee.cmd is launched, which launches cmd.exe, which starts node.exe as a child process
+ // child.kill() would only kill cmd.exe, not node.exe
+ // Therefore we use the Windows taskkill utility to kill the process and all its children (/T for tree)
+ if (isWindows) {
+ // For the on('exit', ...) handler above the following looks like a crash, so we set the killedAfterChange flag
+ killedAfterChange = true;
+ // Force kill (/F) the whole child tree (/T) by PID (/PID 123)
+ exec('taskkill /pid '+child.pid+' /T /F');
+ } else {
+ child.kill('SIGUSR2');
+ }
+ } else {
+ startNode();
+ }
+}
+
function addIgnoreRule(line, noEscape) {
// remove comments and trim lines
// this mess of replace methods is escaping "\#" to allow for emacs temp files
Something went wrong with that request. Please try again.