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

watchify

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watchify - npm Package Compare versions

Comparing version 0.5.6 to 0.6.0

23

bin/cmd.js

@@ -12,2 +12,9 @@ #!/usr/bin/env node

function showError (err) {
if (String(err) !== String(prevErr)) {
console.error(err);
}
prevErr = err;
}
(function retry () {

@@ -25,8 +32,6 @@ w = watchify(fromArgs(process.argv.slice(2)));

w.on('update', bundle);
w.once('error', function (err) {
if (String(err) !== String(prevErr)) {
console.error(err);
}
prevErr = err;
retry();
w.on('error', function (err) {
showError(err);
w.removeListener('update', bundle);
setTimeout(retry, w.argv.delay || 600);
});

@@ -40,3 +45,4 @@ bundle();

wb.on('error', function (err) {
console.error(String(err));
showError(err);
caught = true;
});

@@ -48,6 +54,7 @@ wb.pipe(fs.createWriteStream(dotfile));

function write (buf) { bytes += buf.length }
function end () {
prevErr = undefined;
first = false;
if (caught) return;
fs.rename(dotfile, outfile, function (err) {

@@ -54,0 +61,0 @@ if (err) return console.error(err);

@@ -40,2 +40,22 @@ var through = require('through');

var fwatchers = {};
b.on('bundle', function (bundle) {
bundle.on('transform', function (tr, mfile) {
tr.on('error', b.emit.bind(b, 'error'));
if (!fwatchers[mfile]) fwatchers[mfile] = [];
tr.on('file', function (file) {
if (fwatchers[mfile].indexOf(file) >= 0) return;
var w = fs.watch(file);
w.on('error', b.emit.bind(b, 'error'));
w.on('change', function () {
invalidate(mfile);
});
fwatchers[mfile].push(w);
});
});
});
var watchers = {};
function addDep (dep) {

@@ -47,21 +67,30 @@ if (watching[dep.id]) return;

var watcher = fs.watch(dep.id);
watcher.on('error', function (err) {
b.emit('error', err);
watchers[dep.id] = watcher;
watcher.on('error', b.emit.bind(b, 'error'));
watcher.on('change', function () {
invalidate(dep.id);
});
watcher.on('change', function(path) {
delete cache[dep.id];
queuedCloses[dep.id] = watcher;
changingDeps[dep.id] = true
// wait for the disk/editor to quiet down first:
if (!pending) setTimeout(function () {
pending = false;
b.emit('update', Object.keys(changingDeps));
changingDeps = {};
}, opts.delay || 600);
pending = true;
});
}
function invalidate (id) {
delete cache[id];
if (fwatchers[id]) {
fwatchers[id].forEach(function (w) {
queuedCloses[id + '-' + id] = w;
});
delete fwatchers[id];
}
queuedCloses[id] = watchers[id];
changingDeps[id] = true
// wait for the disk/editor to quiet down first:
if (!pending) setTimeout(function () {
pending = false;
b.emit('update', Object.keys(changingDeps));
changingDeps = {};
}, opts.delay || 600);
pending = true;
}
var bundle = b.bundle.bind(b);

@@ -68,0 +97,0 @@ b.bundle = function (opts_, cb) {

{
"name": "watchify",
"version": "0.5.6",
"version": "0.6.0",
"description": "watch mode for browserify builds",

@@ -5,0 +5,0 @@ "main": "index.js",

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