@@ -28,6 +28,7 @@ namespace ts.TestFSWithWatch {
2828 executingFilePath ?: string ;
2929 currentDirectory ?: string ;
3030 newLine ?: string ;
31+ useWindowsStylePaths ?: boolean ;
3132 }
3233
3334 export function createWatchedSystem ( fileOrFolderList : ReadonlyArray < FileOrFolder > , params ?: TestServerHostCreationParameters ) : TestServerHost {
@@ -39,7 +40,8 @@ namespace ts.TestFSWithWatch {
3940 params . executingFilePath || getExecutingFilePathFromLibFile ( ) ,
4041 params . currentDirectory || "/" ,
4142 fileOrFolderList ,
42- params . newLine ) ;
43+ params . newLine ,
44+ params . useWindowsStylePaths ) ;
4345 return host ;
4446 }
4547
@@ -52,7 +54,8 @@ namespace ts.TestFSWithWatch {
5254 params . executingFilePath || getExecutingFilePathFromLibFile ( ) ,
5355 params . currentDirectory || "/" ,
5456 fileOrFolderList ,
55- params . newLine ) ;
57+ params . newLine ,
58+ params . useWindowsStylePaths ) ;
5659 return host ;
5760 }
5861
@@ -230,11 +233,14 @@ namespace ts.TestFSWithWatch {
230233 readonly watchedDirectories = createMultiMap < TestDirectoryWatcher > ( ) ;
231234 readonly watchedDirectoriesRecursive = createMultiMap < TestDirectoryWatcher > ( ) ;
232235 readonly watchedFiles = createMultiMap < TestFileWatcher > ( ) ;
236+ private readonly executingFilePath : string ;
237+ private readonly currentDirectory : string ;
233238
234- constructor ( public withSafeList : boolean , public useCaseSensitiveFileNames : boolean , private executingFilePath : string , private currentDirectory : string , fileOrFolderList : ReadonlyArray < FileOrFolder > , public readonly newLine = "\n" ) {
239+ constructor ( public withSafeList : boolean , public useCaseSensitiveFileNames : boolean , executingFilePath : string , currentDirectory : string , fileOrFolderList : ReadonlyArray < FileOrFolder > , public readonly newLine = "\n" , public readonly useWindowsStylePath ?: boolean ) {
235240 this . getCanonicalFileName = createGetCanonicalFileName ( useCaseSensitiveFileNames ) ;
236241 this . toPath = s => toPath ( s , currentDirectory , this . getCanonicalFileName ) ;
237-
242+ this . executingFilePath = this . getHostSpecificPath ( executingFilePath ) ;
243+ this . currentDirectory = this . getHostSpecificPath ( currentDirectory ) ;
238244 this . reloadFS ( fileOrFolderList ) ;
239245 }
240246
@@ -250,11 +256,24 @@ namespace ts.TestFSWithWatch {
250256 return this . toPath ( this . toNormalizedAbsolutePath ( s ) ) ;
251257 }
252258
259+ getHostSpecificPath ( s : string ) {
260+ if ( this . useWindowsStylePath && s . startsWith ( directorySeparator ) ) {
261+ return "c:/" + s . substring ( 1 ) ;
262+ }
263+ return s ;
264+ }
265+
253266 reloadFS ( fileOrFolderList : ReadonlyArray < FileOrFolder > ) {
254267 const mapNewLeaves = createMap < true > ( ) ;
255268 const isNewFs = this . fs . size === 0 ;
256- // always inject safelist file in the list of files
257- for ( const fileOrDirectory of fileOrFolderList . concat ( this . withSafeList ? safeList : [ ] ) ) {
269+ fileOrFolderList = fileOrFolderList . concat ( this . withSafeList ? safeList : [ ] ) ;
270+ const filesOrFoldersToLoad : ReadonlyArray < FileOrFolder > = ! this . useWindowsStylePath ? fileOrFolderList :
271+ fileOrFolderList . map < FileOrFolder > ( f => {
272+ const result = clone ( f ) ;
273+ result . path = this . getHostSpecificPath ( f . path ) ;
274+ return result ;
275+ } ) ;
276+ for ( const fileOrDirectory of filesOrFoldersToLoad ) {
258277 const path = this . toFullPath ( fileOrDirectory . path ) ;
259278 mapNewLeaves . set ( path , true ) ;
260279 // If its a change
0 commit comments