watch
Advanced tools
Comparing version 0.13.0 to 0.14.0
10
cli.js
#!/usr/bin/env node | ||
var argv = require('minimist')(process.argv.slice(2)) | ||
var exec = require('child_process').exec | ||
var execshell = require('exec-sh') | ||
var watch = require('./main.js') | ||
@@ -22,7 +22,5 @@ | ||
if(wait) return | ||
var run = exec(command) | ||
run.stdout.pipe(process.stdout) | ||
run.stderr.pipe(process.stderr) | ||
execshell(command) | ||
if(waitTime > 0) { | ||
@@ -29,0 +27,0 @@ wait = true |
35
main.js
@@ -125,2 +125,3 @@ // Copyright 2010-2011 Mikeal Rogers | ||
exports.watchTree(root, options, function (f, curr, prev) { | ||
// if not curr, prev, but f is an object | ||
if (typeof f == "object" && prev == null && curr === null) { | ||
@@ -130,13 +131,33 @@ monitor.files = f; | ||
} | ||
if (prev === null && (prevFile.file != f || prevFile.action != "created")) { | ||
prevFile = { file: f, action: "created", stat: curr }; | ||
return monitor.emit("created", f, curr); | ||
// if not prev and either prevFile.file is not f or prevFile.action is not created | ||
if (!prev) { | ||
if (prevFile.file != f || prevFile.action != "created") { | ||
prevFile = { file: f, action: "created", stat: curr }; | ||
return monitor.emit("created", f, curr); | ||
} | ||
} | ||
if (curr.nlink === 0 && (prevFile.file != f || prevFile.action != "removed")) { | ||
prevFile = { file: f, action: "removed", stat: curr }; | ||
return monitor.emit("removed", f, curr); | ||
// if curr.nlink is 0 and either prevFile.file is not f or prevFile.action is not removed | ||
if (curr) { | ||
if (curr.nlink === 0) { | ||
if (prevFile.file != f || prevFile.action != "removed") { | ||
prevFile = { file: f, action: "removed", stat: curr }; | ||
return monitor.emit("removed", f, curr); | ||
} | ||
} | ||
} | ||
if (prevFile.file === null || prevFile.stat.mtime.getTime() !== curr.mtime.getTime()) { | ||
// if prevFile.file is null or prevFile.stat.mtime is not the same as curr.mtime | ||
if (prevFile.file === null) { | ||
monitor.emit("changed", f, curr, prev); | ||
} | ||
// stat might return null, so catch errors | ||
try { | ||
if (prevFile.stat.mtime.getTime() !== curr.mtime.getTime()) { | ||
monitor.emit("changed", f, curr, prev); | ||
} | ||
} catch(e) { | ||
monitor.emit("changed", f, curr, prev); | ||
} | ||
}) | ||
@@ -143,0 +164,0 @@ } |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"homepage": "https://github.com/mikeal/watch", | ||
@@ -32,4 +32,5 @@ "bugs": { | ||
"dependencies": { | ||
"exec-sh": "^0.2.0", | ||
"minimist": "^1.1.0" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
22094
245
0
2
+ Addedexec-sh@^0.2.0
+ Addedexec-sh@0.2.2(transitive)
+ Addedmerge@1.2.1(transitive)