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

rollup-watch

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-watch - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

5

CHANGELOG.md
# rollup-watch changelog
## 3.2.0
* `options.targets`, not `options.target` ([#36](https://github.com/rollup/rollup-watch/issues/36))
* Use chokidar if available ([#39](https://github.com/rollup/rollup-watch/pull/39))
## 3.1.0

@@ -4,0 +9,0 @@

42

dist/rollup-watch.cjs.js

@@ -6,2 +6,3 @@ 'use strict';

var EventEmitter = _interopDefault(require('events'));
var relative = _interopDefault(require('require-relative'));
var path = require('path');

@@ -27,20 +28,33 @@ var fs = require('fs');

let chokidar;
try {
chokidar = relative( 'chokidar', process.cwd() );
} catch (err) {
chokidar = null;
}
class FileWatcher {
constructor ( file, data, callback, dispose ) {
try {
this.fsWatcher = fs.watch( file, opts, event => {
if ( event === 'rename' ) {
this.fsWatcher.close();
dispose();
const handleWatchEvent = event => {
if ( event === 'rename' || event === 'unlink' ) {
this.fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
}
};
try {
if (chokidar)
{ this.fsWatcher = chokidar.watch(file, { ignoreInitial: true }).on('all', handleWatchEvent); }
else
{ this.fsWatcher = fs.watch( file, opts, handleWatchEvent); }
this.fileExists = true;

@@ -66,3 +80,3 @@ } catch ( err ) {

const dests = options.dest ? [ path.resolve( options.dest ) ] : options.target.map( target => path.resolve( target.dest ) );
const dests = options.dest ? [ path.resolve( options.dest ) ] : options.targets.map( target => path.resolve( target.dest ) );
let filewatchers = new Map();

@@ -69,0 +83,0 @@

import EventEmitter from 'events';
import relative from 'require-relative';
import { resolve } from 'path';

@@ -24,20 +25,33 @@ import * as path from 'path';

let chokidar;
try {
chokidar = relative( 'chokidar', process.cwd() );
} catch (err) {
chokidar = null;
}
class FileWatcher {
constructor ( file, data, callback, dispose ) {
try {
this.fsWatcher = watch( file, opts, event => {
if ( event === 'rename' ) {
this.fsWatcher.close();
dispose();
const handleWatchEvent = event => {
if ( event === 'rename' || event === 'unlink' ) {
this.fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
const contents = readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
} else {
// this is necessary because we get duplicate events...
const contents = readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
}
};
try {
if (chokidar)
{ this.fsWatcher = chokidar.watch(file, { ignoreInitial: true }).on('all', handleWatchEvent); }
else
{ this.fsWatcher = watch( file, opts, handleWatchEvent); }
this.fileExists = true;

@@ -63,3 +77,3 @@ } catch ( err ) {

const dests = options.dest ? [ resolve( options.dest ) ] : options.target.map( target => resolve( target.dest ) );
const dests = options.dest ? [ resolve( options.dest ) ] : options.targets.map( target => resolve( target.dest ) );
let filewatchers = new Map();

@@ -66,0 +80,0 @@

{
"name": "rollup-watch",
"version": "3.1.0",
"version": "3.2.0",
"description": "Watch files for changes and perform incremental rebuilds with Rollup",

@@ -34,2 +34,3 @@ "main": "dist/rollup-watch.cjs.js",

"mocha": "^3.2.0",
"require-relative": "0.8.7",
"rollup": "^0.39.0",

@@ -36,0 +37,0 @@ "rollup-plugin-buble": "^0.15.0",

import EventEmitter from 'events';
import relative from 'require-relative';
import * as path from 'path';

@@ -8,20 +9,33 @@ import * as fs from 'fs';

let chokidar;
try {
chokidar = relative( 'chokidar', process.cwd() );
} catch (err) {
chokidar = null;
}
class FileWatcher {
constructor ( file, data, callback, dispose ) {
try {
this.fsWatcher = fs.watch( file, opts, event => {
if ( event === 'rename' ) {
this.fsWatcher.close();
dispose();
const handleWatchEvent = event => {
if ( event === 'rename' || event === 'unlink' ) {
this.fsWatcher.close();
dispose();
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
} else {
// this is necessary because we get duplicate events...
const contents = fs.readFileSync( file, 'utf-8' );
if ( contents !== data ) {
data = contents;
callback();
}
}
});
}
};
try {
if (chokidar)
this.fsWatcher = chokidar.watch(file, { ignoreInitial: true }).on('all', handleWatchEvent);
else
this.fsWatcher = fs.watch( file, opts, handleWatchEvent);
this.fileExists = true;

@@ -47,3 +61,3 @@ } catch ( err ) {

const dests = options.dest ? [ path.resolve( options.dest ) ] : options.target.map( target => path.resolve( target.dest ) );
const dests = options.dest ? [ path.resolve( options.dest ) ] : options.targets.map( target => path.resolve( target.dest ) );
let filewatchers = new Map();

@@ -50,0 +64,0 @@

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