File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ exports.watch = function(options, callback) {
2828 var watchersActive = false ;
2929
3030 options . extension = function ( inputPath , outputPath ) {
31+ // do not add watcher if file is already watched
32+ for ( var i = 0 ; i < watchers . length ; i ++ ) {
33+ if ( watchers [ i ] . path === inputPath ) {
34+ return ;
35+ }
36+ } ;
3137 var watcher = fs . watch ( inputPath , function ( event , filename ) {
3238 if ( ! watchersActive ) { return ; }
3339
@@ -52,7 +58,7 @@ exports.watch = function(options, callback) {
5258 }
5359 }
5460 } ) ;
55- watchers . push ( watcher ) ;
61+ watchers . push ( { path : inputPath , watcher : watcher } ) ;
5662 } ;
5763
5864 exports . compile ( options , function ( err ) {
@@ -63,7 +69,7 @@ exports.watch = function(options, callback) {
6369
6470 function stopWatchers ( ) {
6571 for ( var i = 0 ; i < watchers . length ; i ++ ) {
66- watchers [ i ] . close ( ) ;
72+ watchers [ i ] . watcher . close ( ) ;
6773 } ;
6874 }
6975} ;
You can’t perform that action at this time.
0 commit comments