Skip to content

Commit

Permalink
Merge pull request remy#106 from dylanmcd/master
Browse files Browse the repository at this point in the history
Fix remy#104 and remy#105, move the tests and starting process to it's own function that starts at the end of the file to avoid calling undefined variables.
  • Loading branch information
remy committed Jun 7, 2012
2 parents e982057 + fc50eaa commit 2d9b976
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions nodemon.js
Expand Up @@ -39,30 +39,34 @@ var fs = require('fs'),
program = getNodemonArgs(),
watched = [];



// test to see if the version of find being run supports searching by seconds (-mtime -1s -print)
if (noWatch) {
exec('find -L /dev/null -type f -mtime -1s -print', function(error, stdout, stderr) {
if (error) {
if (!fs.watch) {
util.error('\x1B[1;31mThe version of node you are using combined with the version of find being used does not support watching files. Upgrade to a newer version of node, or install a version of find that supports search by seconds.\x1B[0m');
process.exit(1);
var testAndStart = function() {
if (noWatch) {
exec('find -L /dev/null -type f -mtime -1s -print', function(error, stdout, stderr) {
if (error) {
if (!fs.watch) {
util.error('\x1B[1;31mThe version of node you are using combined with the version of find being used does not support watching files. Upgrade to a newer version of node, or install a version of find that supports search by seconds.\x1B[0m');
process.exit(1);
} else {
noWatch = false;
watchFileChecker.check(function(success) {
watchWorks = success;
startNode();
});
}
} else {
noWatch = false;
watchFileChecker.check(function(success) {
watchWorks = success;
startNode();
});
// Find is compatible with -1s
startNode();
}
} else {
// Find is compatible with -1s
});
} else {
watchFileChecker.check(function(success) {
watchWorks = success;
startNode();
}
});
} else {
watchFileChecker.check(function(success) {
watchWorks = success;
startNode();
});
});
}
}

// This is a fallback function if fs.watch does not work
Expand Down Expand Up @@ -160,6 +164,7 @@ watchFileChecker.verify = function() {
};



function startNode() {
util.log('\x1B[32m[nodemon] starting `' + program.options.exec + ' ' + program.args.join(' ') + '`\x1B[0m');

Expand Down Expand Up @@ -689,3 +694,5 @@ exists(ignoreFilePath, function (exist) {
readIgnoreFile();
}
});

testAndStart();

0 comments on commit 2d9b976

Please sign in to comment.