Skip to content

Commit

Permalink
Don't mutate the original options (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbunton-atlassian authored and levithomason committed Feb 17, 2017
1 parent 5507b7d commit 006443a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.js
Expand Up @@ -69,12 +69,14 @@ var watchedFiles = Object.create(null);

exports.watchTree = function ( root, options, callback ) {
if (!callback) {callback = options; options = {}}
// convert interval to seconds
if (options.interval) {options.interval = options.interval * 1000}
walk(root, options, function (err, files) {
if (err) throw err;
var fileWatcher = function (f) {
fs.watchFile(f, options, function (c, p) {
var fsOptions = {};
if (options.interval) {
fsOptions.interval = options.interval * 1000;
}
fs.watchFile(f, fsOptions, function (c, p) {
// Check if anything actually changed in stat
if (files[f] && !files[f].isDirectory() && c.nlink !== 0 && files[f].mtime.getTime() == c.mtime.getTime()) return;
files[f] = c;
Expand Down

0 comments on commit 006443a

Please sign in to comment.