@@ -12,8 +12,8 @@ import {
1212import debounce from 'lodash.debounce' ;
1313import path from 'path' ;
1414import { FileChangeCollection } from './file-change-collection' ;
15- import { fse , watch } from '../node' ;
16- import { ChangeEvent , FW } from '../node/extend/fs-watch' ;
15+ import { fsWatcher , fsExtra as fse } from '../node' ;
16+ // import { ChangeEvent, FW } from '../node/extend/fs-watch';
1717
1818export interface WatcherOptions {
1919 excludesPattern : ParsedPattern [ ] ;
@@ -126,18 +126,19 @@ export class FWFileSystemWatcherServer implements FileSystemWatcherServer {
126126 ...rawOptions ,
127127 } ;
128128
129- let watcher : FW | undefined = await watch ( basePath , ( events : ChangeEvent [ ] ) => {
129+ const { watch, actions } = fsWatcher ;
130+ let watcher = await watch ( basePath , ( events ) => {
130131 for ( const event of events ) {
131- if ( event . action === watch . actions . CREATED ) {
132+ if ( event . action === actions . CREATED ) {
132133 this . pushAdded ( watcherId , this . resolvePath ( event . directory , event . file ! ) ) ;
133134 }
134- if ( event . action === watch . actions . DELETED ) {
135+ if ( event . action === actions . DELETED ) {
135136 this . pushDeleted ( watcherId , this . resolvePath ( event . directory , event . file ! ) ) ;
136137 }
137- if ( event . action === watch . actions . MODIFIED ) {
138+ if ( event . action === actions . MODIFIED ) {
138139 this . pushUpdated ( watcherId , this . resolvePath ( event . directory , event . file ! ) ) ;
139140 }
140- if ( event . action === watch . actions . RENAMED ) {
141+ if ( event . action === actions . RENAMED ) {
141142 if ( event . newDirectory ) {
142143 this . pushDeleted ( watcherId , this . resolvePath ( event . directory , event . oldFile ! ) ) ;
143144 this . pushAdded ( watcherId , this . resolvePath ( event . newDirectory , event . newFile ! ) ) ;
@@ -153,7 +154,6 @@ export class FWFileSystemWatcherServer implements FileSystemWatcherServer {
153154 if ( toDisposeWatcher . disposed ) {
154155 this . debug ( 'Stopping watching:' , basePath ) ;
155156 watcher . stop ( ) ;
156- watcher = undefined ;
157157 this . options . info ( 'Stopped watching:' , basePath ) ;
158158 return ;
159159 }
@@ -163,7 +163,6 @@ export class FWFileSystemWatcherServer implements FileSystemWatcherServer {
163163 if ( watcher ) {
164164 this . debug ( 'Stopping watching:' , basePath ) ;
165165 watcher . stop ( ) ;
166- watcher = undefined ;
167166 this . options . info ( 'Stopped watching:' , basePath ) ;
168167 }
169168 } )
0 commit comments