@@ -36,6 +36,7 @@ interface Array<T> {}`
3636 currentDirectory ?: string ;
3737 newLine ?: string ;
3838 useWindowsStylePaths ?: boolean ;
39+ environmentVariables ?: Map < string > ;
3940 }
4041
4142 export function createWatchedSystem ( fileOrFolderList : ReadonlyArray < FileOrFolder > , params ?: TestServerHostCreationParameters ) : TestServerHost {
@@ -48,7 +49,8 @@ interface Array<T> {}`
4849 params . currentDirectory || "/" ,
4950 fileOrFolderList ,
5051 params . newLine ,
51- params . useWindowsStylePaths ) ;
52+ params . useWindowsStylePaths ,
53+ params . environmentVariables ) ;
5254 return host ;
5355 }
5456
@@ -62,7 +64,8 @@ interface Array<T> {}`
6264 params . currentDirectory || "/" ,
6365 fileOrFolderList ,
6466 params . newLine ,
65- params . useWindowsStylePaths ) ;
67+ params . useWindowsStylePaths ,
68+ params . environmentVariables ) ;
6669 return host ;
6770 }
6871
@@ -75,6 +78,7 @@ interface Array<T> {}`
7578 interface FSEntry {
7679 path : Path ;
7780 fullPath : string ;
81+ modifiedTime : Date ;
7882 }
7983
8084 interface File extends FSEntry {
@@ -259,7 +263,7 @@ interface Array<T> {}`
259263 private readonly executingFilePath : string ;
260264 private readonly currentDirectory : string ;
261265
262- constructor ( public withSafeList : boolean , public useCaseSensitiveFileNames : boolean , executingFilePath : string , currentDirectory : string , fileOrFolderList : ReadonlyArray < FileOrFolder > , public readonly newLine = "\n" , public readonly useWindowsStylePath ?: boolean ) {
266+ constructor ( public withSafeList : boolean , public useCaseSensitiveFileNames : boolean , executingFilePath : string , currentDirectory : string , fileOrFolderList : ReadonlyArray < FileOrFolder > , public readonly newLine = "\n" , public readonly useWindowsStylePath ?: boolean , private readonly environmentVariables ?: Map < string > ) {
263267 this . getCanonicalFileName = createGetCanonicalFileName ( useCaseSensitiveFileNames ) ;
264268 this . toPath = s => toPath ( s , currentDirectory , this . getCanonicalFileName ) ;
265269 this . executingFilePath = this . getHostSpecificPath ( executingFilePath ) ;
@@ -307,6 +311,7 @@ interface Array<T> {}`
307311 // Update file
308312 if ( currentEntry . content !== fileOrDirectory . content ) {
309313 currentEntry . content = fileOrDirectory . content ;
314+ currentEntry . modifiedTime = new Date ( ) ;
310315 if ( options && options . invokeDirectoryWatcherInsteadOfFileChanged ) {
311316 this . invokeDirectoryWatcher ( getDirectoryPath ( currentEntry . fullPath ) , currentEntry . fullPath ) ;
312317 }
@@ -326,6 +331,7 @@ interface Array<T> {}`
326331 }
327332 else {
328333 // Folder update: Nothing to do.
334+ currentEntry . modifiedTime = new Date ( ) ;
329335 }
330336 }
331337 }
@@ -416,6 +422,7 @@ interface Array<T> {}`
416422
417423 private addFileOrFolderInFolder ( folder : Folder , fileOrDirectory : File | Folder , ignoreWatch ?: boolean ) {
418424 folder . entries . push ( fileOrDirectory ) ;
425+ folder . modifiedTime = new Date ( ) ;
419426 this . fs . set ( fileOrDirectory . path , fileOrDirectory ) ;
420427
421428 if ( ignoreWatch ) {
@@ -432,6 +439,7 @@ interface Array<T> {}`
432439 const baseFolder = this . fs . get ( basePath ) as Folder ;
433440 if ( basePath !== fileOrDirectory . path ) {
434441 Debug . assert ( ! ! baseFolder ) ;
442+ baseFolder . modifiedTime = new Date ( ) ;
435443 filterMutate ( baseFolder . entries , entry => entry !== fileOrDirectory ) ;
436444 }
437445 this . fs . delete ( fileOrDirectory . path ) ;
@@ -493,30 +501,39 @@ interface Array<T> {}`
493501 }
494502 }
495503
496- private toFile ( fileOrDirectory : FileOrFolder ) : File {
497- const fullPath = getNormalizedAbsolutePath ( fileOrDirectory . path , this . currentDirectory ) ;
504+ private toFsEntry ( path : string ) : FSEntry {
505+ const fullPath = getNormalizedAbsolutePath ( path , this . currentDirectory ) ;
498506 return {
499507 path : this . toPath ( fullPath ) ,
500- content : fileOrDirectory . content ,
501508 fullPath,
502- fileSize : fileOrDirectory . fileSize
509+ modifiedTime : new Date ( )
503510 } ;
504511 }
505512
513+ private toFile ( fileOrDirectory : FileOrFolder ) : File {
514+ const file = this . toFsEntry ( fileOrDirectory . path ) as File ;
515+ file . content = fileOrDirectory . content ;
516+ file . fileSize = fileOrDirectory . fileSize ;
517+ return file ;
518+ }
519+
506520 private toFolder ( path : string ) : Folder {
507- const fullPath = getNormalizedAbsolutePath ( path , this . currentDirectory ) ;
508- return {
509- path : this . toPath ( fullPath ) ,
510- entries : [ ] ,
511- fullPath
512- } ;
521+ const folder = this . toFsEntry ( path ) as Folder ;
522+ folder . entries = [ ] ;
523+ return folder ;
513524 }
514525
515526 fileExists ( s : string ) {
516527 const path = this . toFullPath ( s ) ;
517528 return isFile ( this . fs . get ( path ) ) ;
518529 }
519530
531+ getModifiedTime ( s : string ) {
532+ const path = this . toFullPath ( s ) ;
533+ const fsEntry = this . fs . get ( path ) ;
534+ return fsEntry && fsEntry . modifiedTime ;
535+ }
536+
520537 readFile ( s : string ) {
521538 const fsEntry = this . fs . get ( this . toFullPath ( s ) ) ;
522539 return isFile ( fsEntry ) ? fsEntry . content : undefined ;
@@ -624,7 +641,7 @@ interface Array<T> {}`
624641 this . timeoutCallbacks . invoke ( timeoutId ) ;
625642 }
626643 catch ( e ) {
627- if ( e . message === this . existMessage ) {
644+ if ( e . message === this . exitMessage ) {
628645 return ;
629646 }
630647 throw e ;
@@ -682,15 +699,17 @@ interface Array<T> {}`
682699 clear ( this . output ) ;
683700 }
684701
685- readonly existMessage = "System Exit" ;
702+ readonly exitMessage = "System Exit" ;
686703 exitCode : number ;
687704 readonly resolvePath = ( s : string ) => s ;
688705 readonly getExecutingFilePath = ( ) => this . executingFilePath ;
689706 readonly getCurrentDirectory = ( ) => this . currentDirectory ;
690707 exit ( exitCode ?: number ) {
691708 this . exitCode = exitCode ;
692- throw new Error ( this . existMessage ) ;
709+ throw new Error ( this . exitMessage ) ;
710+ }
711+ getEnvironmentVariable ( name : string ) {
712+ return this . environmentVariables && this . environmentVariables . get ( name ) ;
693713 }
694- readonly getEnvironmentVariable = notImplemented ;
695714 }
696715}
0 commit comments