File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,10 @@ namespace ts {
476
476
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
477
477
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
478
478
let options : any ;
479
+ if ( ! directoryExists ( directoryName ) ) {
480
+ return ;
481
+ }
482
+
479
483
if ( isNode4OrLater ( ) && ( process . platform === "win32" || process . platform === "darwin" ) ) {
480
484
options = { persistent : true , recursive : ! ! recursive } ;
481
485
}
Original file line number Diff line number Diff line change @@ -2387,4 +2387,33 @@ namespace ts.projectSystem {
2387
2387
assert . isTrue ( errorResult . length === 0 ) ;
2388
2388
} ) ;
2389
2389
} ) ;
2390
+
2391
+ describe ( "non-existing directories listed in config file input array" , ( ) => {
2392
+ it ( "should be tolerated without crashing the server" , ( ) => {
2393
+ const configFile = {
2394
+ path : "/a/b/tsconfig.json" ,
2395
+ content : `{
2396
+ "compilerOptions": {},
2397
+ "include": ["app/*", "test/**/*", "something"]
2398
+ }`
2399
+ } ;
2400
+ const file1 = {
2401
+ path : "/a/b/file1.ts" ,
2402
+ content : "let t = 10;"
2403
+ } ;
2404
+
2405
+ const host = createServerHost ( [ file1 , configFile ] ) ;
2406
+ const projectService = createProjectService ( host ) ;
2407
+ projectService . openClientFile ( file1 . path ) ;
2408
+ host . runQueuedTimeoutCallbacks ( ) ;
2409
+ checkNumberOfConfiguredProjects ( projectService , 1 ) ;
2410
+ checkNumberOfInferredProjects ( projectService , 1 ) ;
2411
+
2412
+ const configuredProject = projectService . configuredProjects [ 0 ] ;
2413
+ assert . isTrue ( configuredProject . getFileNames ( ) . length == 0 ) ;
2414
+
2415
+ const inferredProject = projectService . inferredProjects [ 0 ] ;
2416
+ assert . isTrue ( inferredProject . containsFile ( < server . NormalizedPath > file1 . path ) ) ;
2417
+ } ) ;
2418
+ } ) ;
2390
2419
}
Original file line number Diff line number Diff line change @@ -710,7 +710,7 @@ namespace ts.server {
710
710
Debug . assert ( ! ! parsedCommandLine . fileNames ) ;
711
711
712
712
if ( parsedCommandLine . fileNames . length === 0 ) {
713
- errors . push ( createCompilerDiagnostic ( Diagnostics . The_config_file_0_found_doesn_t_contain_any_source_files , configFilename ) ) ;
713
+ ( errors || ( errors = [ ] ) ) . push ( createCompilerDiagnostic ( Diagnostics . The_config_file_0_found_doesn_t_contain_any_source_files , configFilename ) ) ;
714
714
return { success : false , configFileErrors : errors } ;
715
715
}
716
716
You can’t perform that action at this time.
0 commit comments