rollup-watch
Advanced tools
Comparing version 3.1.0 to 3.2.0
# 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 @@ |
@@ -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 @@ |
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
17769
562
7