rollup-watch
Advanced tools
Comparing version 2.2.0 to 2.3.0
# rollup-watch changelog | ||
## 2.3.0 | ||
* Handle `rename` events ([#4](https://github.com/rollup/rollup-watch/issues/4)) | ||
## 2.2.0 | ||
@@ -4,0 +8,0 @@ |
@@ -28,3 +28,3 @@ 'use strict'; | ||
var name = "rollup-watch"; | ||
var version = "2.2.0"; | ||
var version = "2.3.0"; | ||
@@ -47,9 +47,15 @@ function checkVersion ( name, localVersion ) { | ||
var FileWatcher = function FileWatcher ( file, data, callback ) { | ||
fs.watch( file, { encoding: 'utf-8', persistent: true }, function () { | ||
// this is necessary because we get duplicate events... | ||
var contents = fs.readFileSync( file, 'utf-8' ); | ||
if ( contents !== data ) { | ||
data = contents; | ||
var FileWatcher = function FileWatcher ( file, data, callback, dispose ) { | ||
var fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, function (event) { | ||
if ( event === 'rename' ) { | ||
fsWatcher.close(); | ||
dispose(); | ||
callback(); | ||
} else { | ||
// this is necessary because we get duplicate events... | ||
var contents = fs.readFileSync( file, 'utf-8' ); | ||
if ( contents !== data ) { | ||
data = contents; | ||
callback(); | ||
} | ||
} | ||
@@ -108,3 +114,6 @@ }); | ||
if ( !filewatchers.has( id ) ) { | ||
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild ); | ||
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () { | ||
filewatchers.delete( id ); | ||
}); | ||
filewatchers.set( id, watcher ); | ||
@@ -111,0 +120,0 @@ } |
@@ -24,3 +24,3 @@ import EventEmitter from 'events'; | ||
var name = "rollup-watch"; | ||
var version = "2.2.0"; | ||
var version = "2.3.0"; | ||
@@ -43,9 +43,15 @@ function checkVersion ( name, localVersion ) { | ||
var FileWatcher = function FileWatcher ( file, data, callback ) { | ||
fs.watch( file, { encoding: 'utf-8', persistent: true }, function () { | ||
// this is necessary because we get duplicate events... | ||
var contents = fs.readFileSync( file, 'utf-8' ); | ||
if ( contents !== data ) { | ||
data = contents; | ||
var FileWatcher = function FileWatcher ( file, data, callback, dispose ) { | ||
var fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, function (event) { | ||
if ( event === 'rename' ) { | ||
fsWatcher.close(); | ||
dispose(); | ||
callback(); | ||
} else { | ||
// this is necessary because we get duplicate events... | ||
var contents = fs.readFileSync( file, 'utf-8' ); | ||
if ( contents !== data ) { | ||
data = contents; | ||
callback(); | ||
} | ||
} | ||
@@ -104,3 +110,6 @@ }); | ||
if ( !filewatchers.has( id ) ) { | ||
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild ); | ||
var watcher = new FileWatcher( id, module.originalCode, triggerRebuild, function () { | ||
filewatchers.delete( id ); | ||
}); | ||
filewatchers.set( id, watcher ); | ||
@@ -107,0 +116,0 @@ } |
{ | ||
"name": "rollup-watch", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Watch files for changes and perform incremental rebuilds with Rollup", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-watch.cjs.js", |
@@ -8,9 +8,15 @@ import EventEmitter from 'events'; | ||
class FileWatcher { | ||
constructor ( file, data, callback ) { | ||
fs.watch( file, { encoding: 'utf-8', persistent: true }, () => { | ||
// this is necessary because we get duplicate events... | ||
const contents = fs.readFileSync( file, 'utf-8' ); | ||
if ( contents !== data ) { | ||
data = contents; | ||
constructor ( file, data, callback, dispose ) { | ||
const fsWatcher = fs.watch( file, { encoding: 'utf-8', persistent: true }, event => { | ||
if ( event === 'rename' ) { | ||
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(); | ||
} | ||
} | ||
@@ -70,3 +76,6 @@ }); | ||
if ( !filewatchers.has( id ) ) { | ||
const watcher = new FileWatcher( id, module.originalCode, triggerRebuild ); | ||
const watcher = new FileWatcher( id, module.originalCode, triggerRebuild, () => { | ||
filewatchers.delete( id ); | ||
}); | ||
filewatchers.set( id, watcher ); | ||
@@ -73,0 +82,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12722
367