Upstream mrmlnc/fast-glob state of the touched files before 0754373f47
This commit is contained in:
commit
ed3aca1ad6
3 files changed
+528
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import * as path from 'node:path';
|
||||
import * as fsStat from '@nodelib/fs.stat';
|
||||
import * as utils from '../utils/index.js';
|
||||
import type Settings from '../settings.js';
|
||||
import type {
|
||||
Entry,
|
||||
ErrnoException,
|
||||
FsStats,
|
||||
Pattern,
|
||||
ReaderOptions,
|
||||
} from '../types/index.js';
|
||||
|
||||
export abstract class Reader<T> {
|
||||
readonly #settings: Settings;
|
||||
|
||||
protected readonly _fsStatSettings: fsStat.Settings;
|
||||
|
||||
constructor(settings: Settings) {
|
||||
this.#settings = settings;
|
||||
|
||||
this._fsStatSettings = new fsStat.Settings({
|
||||
followSymbolicLink: settings.followSymbolicLinks,
|
||||
fs: settings.fs,
|
||||
throwErrorOnBrokenSymbolicLink: settings.throwErrorOnBrokenSymbolicLink,
|
||||
});
|
||||
}
|
||||
|
||||
public abstract dynamic(root: string, options: ReaderOptions): T;
|
||||
public abstract static(patterns: Pattern[], options: ReaderOptions): T;
|
||||
|
||||
protected _getFullEntryPath(filepath: string): string {
|
||||
return path.resolve(this.#settings.cwd, filepath);
|
||||
}
|
||||
|
||||
protected _makeEntry(stats: FsStats, pattern: Pattern): Entry {
|
||||
const entry: Entry = {
|
||||
name: pattern,
|
||||
path: pattern,
|
||||
dirent: utils.fs.createDirentFromStats(pattern, stats),
|
||||
};
|
||||
|
||||
if (this.#settings.stats) {
|
||||
entry.stats = stats;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
protected _isFatalError(error: ErrnoException): boolean {
|
||||
if (this.#settings.errorFilter !== undefined) {
|
||||
return !this.#settings.errorFilter(error);
|
||||
}
|
||||
|
||||
return !utils.errno.isEnoentCodeError(error) && !utils.errno.isEnotdirCodeError(error);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user