提交 1f152ab5 编写于 作者: B Benjamin Pasero

File picker: bypass exclude rules when picking a full file path (fixes #1445)

上级 b20452d3
......@@ -67,6 +67,14 @@ export class FileWalker {
// Reset state
this.resetState();
// Support that the file pattern is a full path to a file that exists
this.checkFilePatternMatch(rootPaths, (exists) => {
// Report result from file pattern if matching
if (exists) {
onResult({ path: this.filePattern });
}
// For each source
flow.parallel(rootPaths, (absolutePath, perEntryCallback) => {
......@@ -111,6 +119,21 @@ export class FileWalker {
}, (err, result) => {
done(err ? err[0] : null, this.isLimitHit);
});
});
}
private checkFilePatternMatch(rootPaths: string[], clb: (exists: boolean) => void): void {
if (!this.filePattern || !paths.isAbsolute(this.filePattern)) {
return clb(false);
}
if (rootPaths && rootPaths.some(r => r === this.filePattern)) {
return clb(false); // root paths matches are handled already (prevents duplicates)
}
return fs.stat(this.filePattern, (error, stat) => {
return clb(!error && !stat.isDirectory()); // only existing files
});
}
private doWalk(absolutePath: string, relativeParentPath: string, files: string[], onResult: (result: ISerializedFileMatch) => void, done: (error: Error, result: any) => void): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册