Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #106 from dylanmcd/master

Fix #104 and #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...
commit 2d9b9761f23c80e1a2558d5b4fddfb4503f0d6ef 2 parents e982057 + fc50eaa
@remy authored
Showing with 27 additions and 20 deletions.
  1. +27 −20 nodemon.js
View
47 nodemon.js
@@ -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
@@ -160,6 +164,7 @@ watchFileChecker.verify = function() {
};
+
function startNode() {
util.log('\x1B[32m[nodemon] starting `' + program.options.exec + ' ' + program.args.join(' ') + '`\x1B[0m');
@@ -689,3 +694,5 @@ exists(ignoreFilePath, function (exist) {
readIgnoreFile();
}
});
+
+testAndStart();
Please sign in to comment.
Something went wrong with that request. Please try again.