Skip to content

Commit

Permalink
Use find on linux (as per mac)
Browse files Browse the repository at this point in the history
Though the command is slightly different, so fork the code logic. This will still fall back to alternative method if find isn't available.

Ref #419
  • Loading branch information
remy committed Jan 5, 2015
1 parent bdf1fc6 commit 7e63029
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/config/checkWatchSupport.js
Expand Up @@ -44,9 +44,10 @@ function checkWatchSupport(config, callback) {
// up all over your screen like this: http://d.pr/i/R6B8+
// even with higher ulimit -n Mac has another problem: https://github.com/joyent/node/issues/5463
// This will be fixed in 0.12, before then we default to find
config.system.useFind = utils.isMac || !fs.watch;
config.system.useFind = utils.isMac || utils.isLinux || !fs.watch;
var mtime = utils.isMac ? '-mtime -1s' : '-mmin -0.01';
if (config.system.useFind) {
exec('find -L /dev/null -type f -mtime -1s -print', function(error) {
exec('find -L /dev/null -type f ' + mtime + ' -print', function(error) {
if (error) {
if (!fs.watch) {
utils.log.error('The 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.');
Expand Down
5 changes: 4 additions & 1 deletion lib/monitor/watch.js
Expand Up @@ -68,9 +68,12 @@ bus.on('config:update', function () {
// command (mac only oddly)
changeFunction = function (lastStarted, callback) {
var cmds = [];
var offset = ((Date.now() - config.lastStarted)/1000|0);
var mtime = utils.isMac ? '-mtime -' + offset + 's' : '-mmin -' + (offset/100);


config.dirs.forEach(function(dir) {
cmds.push('find -L "' + dir + '" ' + ignoredFileTypesForFind(dir) + ' \\( -type f -and -mtime -' + ((Date.now() - config.lastStarted)/1000|0) + 's -print \\)');
cmds.push('find -L "' + dir + '" ' + ignoredFileTypesForFind(dir) + ' \\( -type f -and ' + mtime + ' -print \\)');
});

exec(cmds.join(';'), function (error, stdout) {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/index.js
Expand Up @@ -8,6 +8,7 @@ var utils = module.exports = {
bus: require('./bus'),
isWindows: process.platform === 'win32',
isMac: process.platform === 'darwin',
isLinux: process.platform === 'linux',
isRequired: (function () {
var p = module;
while (p = p.parent) {
Expand Down

0 comments on commit 7e63029

Please sign in to comment.