Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

watch

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watch - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

5

main.js

@@ -54,6 +54,7 @@ // Copyright 2010-2011 Mikeal Rogers

walk(root, function (err, files) {
if (err) throw err;
var fileWatcher = function (f) {
fs.watchFile(f, options, function (c, p) {
// Check if anything actually changed in stat
if (files[f] && !files[f].isDirectory() && c.nlink !== 0 && files[f].ino == c.ino) return;
if (files[f] && !files[f].isDirectory() && c.nlink !== 0 && files[f].mtime == c.mtime) return;
files[f] = c;

@@ -109,2 +110,2 @@ if (!files[f].isDirectory()) callback(f, c, p);

exports.walk = walk;
exports.walk = walk;

2

package.json
{ "name" : "watch"
, "description" : "Utilities for watching file trees."
, "tags" : ["util", "utility", "fs", "files"]
, "version" : "0.3.1"
, "version" : "0.3.2"
, "author" : "Mikeal Rogers <mikeal.rogers@gmail.com>"

@@ -6,0 +6,0 @@ , "directories" :

var watch = require('../main')
, assert = require('assert')
, path = require('path')
, fs = require('fs')
, target = path.join(__dirname, "d/t")
;
watch.createMonitor(__dirname, function (monitor) {
monitor.on('created', function (f) {
console.log('created '+f)
})
monitor.on('removed', function (f) {
console.log('removed '+f)
})
monitor.on('changed', function (f) {
console.log('changed '+f)
})
});
function clearFile() {
fs.writeFileSync(target, '')
}
clearFile()
// test if changed event is fired correctly
watch.createMonitor(__dirname, { interval: 150 },
function (monitor) {
monitor.once('changed', function (f) {
assert.equal(f, target);
clearFile();
process.exit(0)
})
fs.writeFile(target, 'Test Write\n', function (err) {
if (err) throw err;
setTimeout(function () {
// should have got the other assert done by now
assert.ok(false);
}, 300);
})
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc