Skip to content

Commit d3b9ebe

Browse files
committed
JS: Perform glob matching across source roots
1 parent 1297d0f commit d3b9ebe

File tree

1 file changed

+12
-1
lines changed
  • javascript/extractor/lib/typescript/src

1 file changed

+12
-1
lines changed

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,18 @@ function loadTsConfig(command: LoadCommand): LoadedConfig {
414414
*/
415415
let parseConfigHost: ts.ParseConfigHost = {
416416
useCaseSensitiveFileNames: true,
417-
readDirectory: ts.sys.readDirectory, // No need to override traversal/glob matching
417+
readDirectory: (rootDir, extensions, excludes?, includes?, depth?) => {
418+
// Perform the glob matching in both real and virtual source roots.
419+
let originalResults = ts.sys.readDirectory(rootDir, extensions, excludes, includes, depth)
420+
let virtualDir = virtualSourceRoot.toVirtualPath(rootDir);
421+
if (virtualDir == null) {
422+
return originalResults;
423+
}
424+
// Make sure glob matching does not to discover anything in node_modules.
425+
let virtualExcludes = [ ...(excludes || []), '**/node_modules/**/*' ];
426+
let virtualResults = ts.sys.readDirectory(virtualDir, extensions, virtualExcludes, includes, depth)
427+
return [ ...originalResults, ...virtualResults ];
428+
},
418429
fileExists: (path: string) => {
419430
return ts.sys.fileExists(path)
420431
|| virtualSourceRoot.toVirtualPathIfFileExists(path) != null

0 commit comments

Comments
 (0)