mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
fix: restore file count in verbose mode
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* This is *not* the user's config.
|
||||
*/
|
||||
var debug = require('debug')('nodemon');
|
||||
var load = require('./load');
|
||||
var rules = require('../rules');
|
||||
var utils = require('../utils');
|
||||
@@ -24,9 +25,6 @@ var config = {
|
||||
run: false,
|
||||
system: {
|
||||
cwd: process.cwd(),
|
||||
useFind: false,
|
||||
useWatch: false,
|
||||
useWatchFile: false,
|
||||
},
|
||||
required: false,
|
||||
dirs: [],
|
||||
@@ -70,6 +68,7 @@ config.load = function (settings, ready) {
|
||||
options.monitor = rulesToMonitor(options.watch, options.ignore, config);
|
||||
|
||||
var cwd = process.cwd();
|
||||
debug('config: dirs', config.dirs);
|
||||
if (config.dirs.length === 0) {
|
||||
config.dirs.unshift(cwd);
|
||||
}
|
||||
|
||||
@@ -61,11 +61,8 @@ function rulesToMonitor(watch, ignore, config) {
|
||||
}
|
||||
rule += '**/*';
|
||||
|
||||
// only needed for mac, because on mac we use `find` and it needs some
|
||||
// narrowing down otherwise it tries to find on the entire drive...which
|
||||
// is a bit batty.
|
||||
// `!not` ... sorry.
|
||||
if (config.system.useFind && !not) {
|
||||
if (!not) {
|
||||
config.dirs.push(dir);
|
||||
}
|
||||
} else {
|
||||
@@ -75,7 +72,7 @@ function rulesToMonitor(watch, ignore, config) {
|
||||
}
|
||||
} catch (e) {
|
||||
var base = tryBaseDir(dir);
|
||||
if (config.system.useFind && !not && base) {
|
||||
if (!not && base) {
|
||||
if (config.dirs.indexOf(base) === -1) {
|
||||
config.dirs.push(base);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module.exports = watch;
|
||||
|
||||
var debug = require('debug')('nodemon');
|
||||
var Promise = require('es6-promise').Promise; // jshint ignore:line
|
||||
var chokidar = require('chokidar');
|
||||
var undefsafe = require('undefsafe');
|
||||
var config = require('../config');
|
||||
@@ -29,19 +30,40 @@ function watch() {
|
||||
|
||||
debug('start watch on: %s', dirs.join(', '));
|
||||
|
||||
var promises = [];
|
||||
|
||||
dirs.forEach(function (dir) {
|
||||
var watcher = chokidar.watch(dir, {
|
||||
// ignore our files, but also ignore dotfiles
|
||||
ignored: [config.options.ignore.re, /[\/\\]\./],
|
||||
persistent: true,
|
||||
});
|
||||
var promise = new Promise(function (resolve) {
|
||||
var watcher = chokidar.watch(dir, {
|
||||
// ignore our files, but also ignore dotfiles
|
||||
ignored: [config.options.ignore.re, /[\/\\]\./],
|
||||
persistent: true,
|
||||
});
|
||||
|
||||
var total = 0;
|
||||
|
||||
watcher.on('change', filterAndRestart);
|
||||
watcher.on('addDir', function (arg) {
|
||||
debug('watching dir: %s', arg);
|
||||
watcher.on('change', filterAndRestart);
|
||||
watcher.on('add', function (arg) {
|
||||
total++;
|
||||
debug('watching dir: %s', arg);
|
||||
});
|
||||
watcher.on('ready', function () {
|
||||
resolve(total);
|
||||
});
|
||||
|
||||
watchers.push(watcher);
|
||||
});
|
||||
watchers.push(watcher);
|
||||
promises.push(promise);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(function (res) {
|
||||
var total = res.reduce(function (acc, curr) {
|
||||
acc += curr;
|
||||
return acc;
|
||||
}, 0);
|
||||
|
||||
var count = total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
utils.log.detail('watching ' + count + ' files');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"dependencies": {
|
||||
"chokidar": "^1.0.5",
|
||||
"debug": "^2.2.0",
|
||||
"es6-promise": "^3.0.2",
|
||||
"lodash.defaults": "^3.1.2",
|
||||
"minimatch": "~0.3.0",
|
||||
"ps-tree": "~0.0.3",
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('nodemon rules', function () {
|
||||
regexp: loadfixtures('regexp'),
|
||||
default: loadfixtures('default'),
|
||||
simple: loadfixtures('simple'),
|
||||
simplejson: loadfixtures('simple.json')
|
||||
simplejson: loadfixtures('simple.json'),
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
|
||||
Reference in New Issue
Block a user