Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion packages/wotan/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class Runner {
): Iterable<{files: Iterable<string>, program: ts.Program}> {
const cwd = unixifyPath(this.directories.getCurrentDirectory());
if (projects.length !== 0) {
projects = projects.map((configFile) => this.checkConfigDirectory(unixifyPath(path.resolve(cwd, configFile))));
projects = this.matchProjectGlobs(projects);
} else if (references) {
projects = [this.checkConfigDirectory(cwd)];
} else {
Expand Down Expand Up @@ -302,6 +302,37 @@ export class Runner {
}
}

private matchProjectGlobs(projects: ReadonlyArray<string>) {
const cwd = this.directories.getCurrentDirectory();
const result = [];
const globOptions: glob.IOptions = {
cwd,
nobrace: true, // braces are already expanded
cache: {},
realpathCache: {},
statCache: {},
symlinks: {},
};
for (const project of projects) {
if (!glob.hasMagic(project)) {
result.push(this.checkConfigDirectory(unixifyPath(path.resolve(cwd, project))));
} else {
let matched = false;
for (const pattern of normalizeGlob(project, cwd)) {
log("globbing project pattern '%s'", pattern);
for (const match of glob.sync(pattern, globOptions)) {
matched = true;
result.push(this.checkConfigDirectory(unixifyPath(match)));
}
}
if (!matched)
throw new ConfigurationError(`The specified pattern does not match any file: '${project}'`);
}

}
return result;
}

private checkConfigDirectory(fileOrDirName: string): string {
switch (this.fs.getKind(fileOrDirName)) {
case FileKind.NonExistent:
Expand Down