Socket
Socket
Sign inDemoInstall

watch

Package Overview
Dependencies
3
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

@@ -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 @@ }

3

package.json

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc