@@ -25,7 +25,7 @@ namespace ts {
25
25
}
26
26
27
27
interface WatchedFile {
28
- fileName : string ;
28
+ filePath : Path ;
29
29
callback : FileWatcherCallback ;
30
30
mtime ?: Date ;
31
31
}
@@ -244,13 +244,13 @@ namespace ts {
244
244
return ;
245
245
}
246
246
247
- _fs . stat ( watchedFile . fileName , ( err : any , stats : any ) => {
247
+ _fs . stat ( watchedFile . filePath , ( err : any , stats : any ) => {
248
248
if ( err ) {
249
- watchedFile . callback ( watchedFile . fileName ) ;
249
+ watchedFile . callback ( watchedFile . filePath ) ;
250
250
}
251
251
else if ( watchedFile . mtime . getTime ( ) !== stats . mtime . getTime ( ) ) {
252
- watchedFile . mtime = getModifiedTime ( watchedFile . fileName ) ;
253
- watchedFile . callback ( watchedFile . fileName , watchedFile . mtime . getTime ( ) === 0 ) ;
252
+ watchedFile . mtime = getModifiedTime ( watchedFile . filePath ) ;
253
+ watchedFile . callback ( watchedFile . filePath , watchedFile . mtime . getTime ( ) === 0 ) ;
254
254
}
255
255
} ) ;
256
256
}
@@ -278,11 +278,11 @@ namespace ts {
278
278
} , interval ) ;
279
279
}
280
280
281
- function addFile ( fileName : string , callback : FileWatcherCallback ) : WatchedFile {
281
+ function addFile ( filePath : Path , callback : FileWatcherCallback ) : WatchedFile {
282
282
const file : WatchedFile = {
283
- fileName ,
283
+ filePath ,
284
284
callback,
285
- mtime : getModifiedTime ( fileName )
285
+ mtime : getModifiedTime ( filePath )
286
286
} ;
287
287
288
288
watchedFiles . push ( file ) ;
@@ -309,7 +309,6 @@ namespace ts {
309
309
const dirWatchers = createFileMap < DirectoryWatcher > ( ) ;
310
310
// One file can have multiple watchers
311
311
const fileWatcherCallbacks = createFileMap < FileWatcherCallback [ ] > ( ) ;
312
- const currentDirectory = process . cwd ( ) ;
313
312
return { addFile, removeFile } ;
314
313
315
314
function reduceDirWatcherRefCount ( dirPath : Path ) {
@@ -355,16 +354,15 @@ namespace ts {
355
354
return undefined ;
356
355
}
357
356
358
- function addFile ( fileName : string , callback : FileWatcherCallback ) : WatchedFile {
359
- const filePath = toPath ( fileName , currentDirectory , getCanonicalPath ) ;
357
+ function addFile ( filePath : Path , callback : FileWatcherCallback ) : WatchedFile {
360
358
addFileWatcherCallback ( filePath , callback ) ;
361
359
addDirWatcher ( getDirectoryPath ( filePath ) ) ;
362
360
363
- return { fileName , callback } ;
361
+ return { filePath , callback } ;
364
362
}
365
363
366
364
function removeFile ( watchedFile : WatchedFile ) {
367
- const filePath = toPath ( watchedFile . fileName , currentDirectory , getCanonicalPath ) ;
365
+ const filePath = watchedFile . filePath ;
368
366
if ( fileWatcherCallbacks . contains ( filePath ) ) {
369
367
const newCallbacks = copyListRemovingItem ( watchedFile . callback , fileWatcherCallbacks . get ( filePath ) ) ;
370
368
if ( newCallbacks . length === 0 ) {
@@ -513,7 +511,7 @@ namespace ts {
513
511
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
514
512
// if the current node.js version is newer than 4, use `fs.watch` instead.
515
513
const watchSet = isNode4OrLater ( ) ? watchedFileSet : pollingWatchedFileSet ;
516
- const watchedFile = watchSet . addFile ( fileName , callback ) ;
514
+ const watchedFile = watchSet . addFile ( < Path > fileName , callback ) ;
517
515
return {
518
516
close : ( ) => watchSet . removeFile ( watchedFile )
519
517
} ;
0 commit comments