fast-glob-fast 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +818 -0
- package/out/index.d.ts +49 -0
- package/out/index.js +99 -0
- package/out/managers/tasks.d.ts +22 -0
- package/out/managers/tasks.js +114 -0
- package/out/providers/async.d.ts +11 -0
- package/out/providers/async.js +24 -0
- package/out/providers/filters/deep.d.ts +7 -0
- package/out/providers/filters/deep.js +64 -0
- package/out/providers/filters/entry.d.ts +8 -0
- package/out/providers/filters/entry.js +88 -0
- package/out/providers/filters/error.d.ts +7 -0
- package/out/providers/filters/error.js +16 -0
- package/out/providers/index.d.ts +3 -0
- package/out/providers/index.js +19 -0
- package/out/providers/matchers/matcher.d.ts +28 -0
- package/out/providers/matchers/matcher.js +48 -0
- package/out/providers/matchers/partial.d.ts +4 -0
- package/out/providers/matchers/partial.js +38 -0
- package/out/providers/provider.d.ts +19 -0
- package/out/providers/provider.js +55 -0
- package/out/providers/stream.d.ts +12 -0
- package/out/providers/stream.js +32 -0
- package/out/providers/sync.d.ts +11 -0
- package/out/providers/sync.js +24 -0
- package/out/providers/transformers/entry.d.ts +7 -0
- package/out/providers/transformers/entry.js +36 -0
- package/out/readers/async.d.ts +16 -0
- package/out/readers/async.js +34 -0
- package/out/readers/index.d.ts +3 -0
- package/out/readers/index.js +19 -0
- package/out/readers/reader.d.ts +13 -0
- package/out/readers/reader.js +36 -0
- package/out/readers/stream.d.ts +16 -0
- package/out/readers/stream.js +58 -0
- package/out/readers/sync.d.ts +15 -0
- package/out/readers/sync.js +41 -0
- package/out/settings.d.ts +162 -0
- package/out/settings.js +75 -0
- package/out/types/index.d.ts +34 -0
- package/out/types/index.js +2 -0
- package/out/utils/array.d.ts +2 -0
- package/out/utils/array.js +22 -0
- package/out/utils/errno.d.ts +2 -0
- package/out/utils/errno.js +6 -0
- package/out/utils/fs.d.ts +9 -0
- package/out/utils/fs.js +30 -0
- package/out/utils/index.d.ts +7 -0
- package/out/utils/index.js +10 -0
- package/out/utils/path.d.ts +10 -0
- package/out/utils/path.js +65 -0
- package/out/utils/pattern.d.ts +49 -0
- package/out/utils/pattern.js +210 -0
- package/out/utils/stream.d.ts +2 -0
- package/out/utils/stream.js +22 -0
- package/out/utils/string.d.ts +8 -0
- package/out/utils/string.js +22 -0
- package/package.json +89 -0
- package/scripts/postinstall-test.mjs +138 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import DeepFilter from './filters/deep';
|
|
2
|
+
import EntryFilter from './filters/entry';
|
|
3
|
+
import ErrorFilter from './filters/error';
|
|
4
|
+
import EntryTransformer from './transformers/entry';
|
|
5
|
+
import type Settings from '../settings';
|
|
6
|
+
import type { MicromatchOptions, ReaderOptions } from '../types';
|
|
7
|
+
import type { Task } from '../managers/tasks';
|
|
8
|
+
export declare abstract class Provider<T> {
|
|
9
|
+
#private;
|
|
10
|
+
readonly errorFilter: ErrorFilter;
|
|
11
|
+
readonly entryFilter: EntryFilter;
|
|
12
|
+
readonly deepFilter: DeepFilter;
|
|
13
|
+
readonly entryTransformer: EntryTransformer;
|
|
14
|
+
constructor(settings: Settings);
|
|
15
|
+
abstract read(_task: Task): T;
|
|
16
|
+
protected _getRootDirectory(task: Task): string;
|
|
17
|
+
protected _getReaderOptions(task: Task): ReaderOptions;
|
|
18
|
+
protected _getMicromatchOptions(): MicromatchOptions;
|
|
19
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Provider = void 0;
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const deep_1 = require("./filters/deep");
|
|
6
|
+
const entry_1 = require("./filters/entry");
|
|
7
|
+
const error_1 = require("./filters/error");
|
|
8
|
+
const entry_2 = require("./transformers/entry");
|
|
9
|
+
class Provider {
|
|
10
|
+
errorFilter;
|
|
11
|
+
entryFilter;
|
|
12
|
+
deepFilter;
|
|
13
|
+
entryTransformer;
|
|
14
|
+
#settings;
|
|
15
|
+
constructor(settings) {
|
|
16
|
+
this.#settings = settings;
|
|
17
|
+
const micromatchOptions = this._getMicromatchOptions();
|
|
18
|
+
this.errorFilter = new error_1.default(settings);
|
|
19
|
+
this.entryFilter = new entry_1.default(settings, micromatchOptions);
|
|
20
|
+
this.deepFilter = new deep_1.default(settings, micromatchOptions);
|
|
21
|
+
this.entryTransformer = new entry_2.default(settings);
|
|
22
|
+
}
|
|
23
|
+
_getRootDirectory(task) {
|
|
24
|
+
return path.resolve(this.#settings.cwd, task.base);
|
|
25
|
+
}
|
|
26
|
+
_getReaderOptions(task) {
|
|
27
|
+
const basePath = task.base === '.' ? '' : task.base;
|
|
28
|
+
return {
|
|
29
|
+
basePath,
|
|
30
|
+
pathSegmentSeparator: '/',
|
|
31
|
+
deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative),
|
|
32
|
+
entryFilter: this.entryFilter.getFilter(task.positive, task.negative),
|
|
33
|
+
errorFilter: this.errorFilter.getFilter(),
|
|
34
|
+
followSymbolicLinks: this.#settings.followSymbolicLinks,
|
|
35
|
+
fs: this.#settings.fs,
|
|
36
|
+
stats: this.#settings.stats,
|
|
37
|
+
throwErrorOnBrokenSymbolicLink: this.#settings.throwErrorOnBrokenSymbolicLink,
|
|
38
|
+
transform: this.entryTransformer.getTransformer(),
|
|
39
|
+
signal: this.#settings.signal,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
_getMicromatchOptions() {
|
|
43
|
+
return {
|
|
44
|
+
dot: this.#settings.dot,
|
|
45
|
+
matchBase: this.#settings.baseNameMatch,
|
|
46
|
+
nobrace: !this.#settings.braceExpansion,
|
|
47
|
+
nocase: !this.#settings.caseSensitiveMatch,
|
|
48
|
+
noext: !this.#settings.extglob,
|
|
49
|
+
noglobstar: !this.#settings.globstar,
|
|
50
|
+
posix: true,
|
|
51
|
+
strictSlashes: false,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Provider = Provider;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { Provider } from './provider';
|
|
3
|
+
import type { IReaderStream } from '../readers';
|
|
4
|
+
import type Settings from '../settings';
|
|
5
|
+
import type { Task } from '../managers/tasks';
|
|
6
|
+
import type { ReaderOptions } from '../types';
|
|
7
|
+
export declare class ProviderStream extends Provider<Readable> {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(reader: IReaderStream, settings: Settings);
|
|
10
|
+
read(task: Task): Readable;
|
|
11
|
+
api(root: string, task: Task, options: ReaderOptions): Readable;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderStream = void 0;
|
|
4
|
+
const node_stream_1 = require("node:stream");
|
|
5
|
+
const provider_1 = require("./provider");
|
|
6
|
+
class ProviderStream extends provider_1.Provider {
|
|
7
|
+
#reader;
|
|
8
|
+
constructor(reader, settings) {
|
|
9
|
+
super(settings);
|
|
10
|
+
this.#reader = reader;
|
|
11
|
+
}
|
|
12
|
+
read(task) {
|
|
13
|
+
const root = this._getRootDirectory(task);
|
|
14
|
+
const options = this._getReaderOptions(task);
|
|
15
|
+
const source = this.api(root, task, options);
|
|
16
|
+
const destination = new node_stream_1.Readable({ objectMode: true, read: () => { } });
|
|
17
|
+
source
|
|
18
|
+
.once('error', (error) => destination.emit('error', error))
|
|
19
|
+
.on('data', (entry) => destination.emit('data', options.transform(entry)))
|
|
20
|
+
.once('end', () => destination.emit('end'));
|
|
21
|
+
destination
|
|
22
|
+
.once('close', () => source.destroy());
|
|
23
|
+
return destination;
|
|
24
|
+
}
|
|
25
|
+
api(root, task, options) {
|
|
26
|
+
if (task.dynamic) {
|
|
27
|
+
return this.#reader.dynamic(root, options);
|
|
28
|
+
}
|
|
29
|
+
return this.#reader.static(task.patterns, options);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ProviderStream = ProviderStream;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Provider } from './provider';
|
|
2
|
+
import type { IReaderSync } from '../readers';
|
|
3
|
+
import type Settings from '../settings';
|
|
4
|
+
import type { Task } from '../managers/tasks';
|
|
5
|
+
import type { Entry, EntryItem, ReaderOptions } from '../types';
|
|
6
|
+
export declare class ProviderSync extends Provider<EntryItem[]> {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(reader: IReaderSync, settings: Settings);
|
|
9
|
+
read(task: Task): EntryItem[];
|
|
10
|
+
api(root: string, task: Task, options: ReaderOptions): Entry[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderSync = void 0;
|
|
4
|
+
const provider_1 = require("./provider");
|
|
5
|
+
class ProviderSync extends provider_1.Provider {
|
|
6
|
+
#reader;
|
|
7
|
+
constructor(reader, settings) {
|
|
8
|
+
super(settings);
|
|
9
|
+
this.#reader = reader;
|
|
10
|
+
}
|
|
11
|
+
read(task) {
|
|
12
|
+
const root = this._getRootDirectory(task);
|
|
13
|
+
const options = this._getReaderOptions(task);
|
|
14
|
+
const entries = this.api(root, task, options);
|
|
15
|
+
return entries.map((entry) => options.transform(entry));
|
|
16
|
+
}
|
|
17
|
+
api(root, task, options) {
|
|
18
|
+
if (task.dynamic) {
|
|
19
|
+
return this.#reader.dynamic(root, options);
|
|
20
|
+
}
|
|
21
|
+
return this.#reader.static(task.patterns, options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ProviderSync = ProviderSync;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const utils = require("../../utils");
|
|
5
|
+
class EntryTransformer {
|
|
6
|
+
#settings;
|
|
7
|
+
#pathSeparatorSymbol;
|
|
8
|
+
constructor(settings) {
|
|
9
|
+
this.#settings = settings;
|
|
10
|
+
this.#pathSeparatorSymbol = this.#getPathSeparatorSymbol();
|
|
11
|
+
}
|
|
12
|
+
getTransformer() {
|
|
13
|
+
return (entry) => this.#transform(entry);
|
|
14
|
+
}
|
|
15
|
+
#transform(entry) {
|
|
16
|
+
let filepath = entry.path;
|
|
17
|
+
if (this.#settings.absolute) {
|
|
18
|
+
filepath = utils.path.makeAbsolute(this.#settings.cwd, filepath);
|
|
19
|
+
filepath = utils.string.flatHeavilyConcatenatedString(filepath);
|
|
20
|
+
}
|
|
21
|
+
if (this.#settings.markDirectories && entry.dirent.isDirectory()) {
|
|
22
|
+
filepath += this.#pathSeparatorSymbol;
|
|
23
|
+
}
|
|
24
|
+
if (!this.#settings.objectMode) {
|
|
25
|
+
return filepath;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...entry,
|
|
29
|
+
path: filepath,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
#getPathSeparatorSymbol() {
|
|
33
|
+
return this.#settings.absolute ? path.sep : '/';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = EntryTransformer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as fsWalk from '@nodelib/fs.walk';
|
|
2
|
+
import { Reader } from './reader';
|
|
3
|
+
import { ReaderStream } from './stream';
|
|
4
|
+
import type Settings from '../settings';
|
|
5
|
+
import type { Entry, ReaderOptions, Pattern } from '../types';
|
|
6
|
+
export interface IReaderAsync {
|
|
7
|
+
dynamic: (root: string, options: ReaderOptions) => Promise<Entry[]>;
|
|
8
|
+
static: (patterns: Pattern[], options: ReaderOptions) => Promise<Entry[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare class ReaderAsync extends Reader<Promise<Entry[]>> implements IReaderAsync {
|
|
11
|
+
protected _walkAsync: typeof fsWalk.walk;
|
|
12
|
+
protected _readerStream: ReaderStream;
|
|
13
|
+
constructor(settings: Settings);
|
|
14
|
+
dynamic(root: string, options: ReaderOptions): Promise<Entry[]>;
|
|
15
|
+
static(patterns: Pattern[], options: ReaderOptions): Promise<Entry[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReaderAsync = void 0;
|
|
4
|
+
const fsWalk = require("@nodelib/fs.walk");
|
|
5
|
+
const reader_1 = require("./reader");
|
|
6
|
+
const stream_1 = require("./stream");
|
|
7
|
+
class ReaderAsync extends reader_1.Reader {
|
|
8
|
+
_walkAsync = fsWalk.walk;
|
|
9
|
+
_readerStream;
|
|
10
|
+
constructor(settings) {
|
|
11
|
+
super(settings);
|
|
12
|
+
this._readerStream = new stream_1.ReaderStream(settings);
|
|
13
|
+
}
|
|
14
|
+
dynamic(root, options) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
this._walkAsync(root, options, (error, entries) => {
|
|
17
|
+
if (error === null) {
|
|
18
|
+
resolve(entries);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
reject(error);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async static(patterns, options) {
|
|
27
|
+
const entries = [];
|
|
28
|
+
for await (const entry of this._readerStream.static(patterns, options)) {
|
|
29
|
+
entries.push(entry);
|
|
30
|
+
}
|
|
31
|
+
return entries;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ReaderAsync = ReaderAsync;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./async"), exports);
|
|
18
|
+
__exportStar(require("./stream"), exports);
|
|
19
|
+
__exportStar(require("./sync"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as fsStat from '@nodelib/fs.stat';
|
|
2
|
+
import type Settings from '../settings';
|
|
3
|
+
import type { Entry, ErrnoException, FsStats, Pattern, ReaderOptions } from '../types';
|
|
4
|
+
export declare abstract class Reader<T> {
|
|
5
|
+
#private;
|
|
6
|
+
protected readonly _fsStatSettings: fsStat.Settings;
|
|
7
|
+
constructor(settings: Settings);
|
|
8
|
+
abstract dynamic(root: string, options: ReaderOptions): T;
|
|
9
|
+
abstract static(patterns: Pattern[], options: ReaderOptions): T;
|
|
10
|
+
protected _getFullEntryPath(filepath: string): string;
|
|
11
|
+
protected _makeEntry(stats: FsStats, pattern: Pattern): Entry;
|
|
12
|
+
protected _isFatalError(error: ErrnoException): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reader = void 0;
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const fsStat = require("@nodelib/fs.stat");
|
|
6
|
+
const utils = require("../utils");
|
|
7
|
+
class Reader {
|
|
8
|
+
_fsStatSettings;
|
|
9
|
+
#settings;
|
|
10
|
+
constructor(settings) {
|
|
11
|
+
this.#settings = settings;
|
|
12
|
+
this._fsStatSettings = new fsStat.Settings({
|
|
13
|
+
followSymbolicLink: settings.followSymbolicLinks,
|
|
14
|
+
fs: settings.fs,
|
|
15
|
+
throwErrorOnBrokenSymbolicLink: settings.throwErrorOnBrokenSymbolicLink,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
_getFullEntryPath(filepath) {
|
|
19
|
+
return path.resolve(this.#settings.cwd, filepath);
|
|
20
|
+
}
|
|
21
|
+
_makeEntry(stats, pattern) {
|
|
22
|
+
const entry = {
|
|
23
|
+
name: pattern,
|
|
24
|
+
path: pattern,
|
|
25
|
+
dirent: utils.fs.createDirentFromStats(pattern, stats),
|
|
26
|
+
};
|
|
27
|
+
if (this.#settings.stats) {
|
|
28
|
+
entry.stats = stats;
|
|
29
|
+
}
|
|
30
|
+
return entry;
|
|
31
|
+
}
|
|
32
|
+
_isFatalError(error) {
|
|
33
|
+
return !utils.errno.isEnoentCodeError(error) && !this.#settings.suppressErrors;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Reader = Reader;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as fsStat from '@nodelib/fs.stat';
|
|
2
|
+
import * as fsWalk from '@nodelib/fs.walk';
|
|
3
|
+
import { Reader } from './reader';
|
|
4
|
+
import type { Pattern, ReaderOptions } from '../types';
|
|
5
|
+
import type { Readable } from 'node:stream';
|
|
6
|
+
export interface IReaderStream {
|
|
7
|
+
dynamic: (root: string, options: ReaderOptions) => Readable;
|
|
8
|
+
static: (patterns: Pattern[], options: ReaderOptions) => Readable;
|
|
9
|
+
}
|
|
10
|
+
export declare class ReaderStream extends Reader<Readable> implements IReaderStream {
|
|
11
|
+
#private;
|
|
12
|
+
protected _walkStream: typeof fsWalk.walkStream;
|
|
13
|
+
protected _stat: typeof fsStat.stat;
|
|
14
|
+
dynamic(root: string, options: ReaderOptions): Readable;
|
|
15
|
+
static(patterns: Pattern[], options: ReaderOptions): Readable;
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReaderStream = void 0;
|
|
4
|
+
const node_stream_1 = require("node:stream");
|
|
5
|
+
const fsStat = require("@nodelib/fs.stat");
|
|
6
|
+
const fsWalk = require("@nodelib/fs.walk");
|
|
7
|
+
const reader_1 = require("./reader");
|
|
8
|
+
class ReaderStream extends reader_1.Reader {
|
|
9
|
+
_walkStream = fsWalk.walkStream;
|
|
10
|
+
_stat = fsStat.stat;
|
|
11
|
+
dynamic(root, options) {
|
|
12
|
+
return this._walkStream(root, options);
|
|
13
|
+
}
|
|
14
|
+
static(patterns, options) {
|
|
15
|
+
const filepaths = patterns.map((pattern) => this._getFullEntryPath(pattern));
|
|
16
|
+
const stream = new node_stream_1.PassThrough({ objectMode: true, signal: options.signal });
|
|
17
|
+
stream._write = (index, _enc, done) => {
|
|
18
|
+
this.#getEntry(filepaths[index], patterns[index], options)
|
|
19
|
+
.then((entry) => {
|
|
20
|
+
if (entry !== null && options.entryFilter(entry)) {
|
|
21
|
+
stream.push(entry);
|
|
22
|
+
}
|
|
23
|
+
if (index === filepaths.length - 1) {
|
|
24
|
+
stream.end();
|
|
25
|
+
}
|
|
26
|
+
done();
|
|
27
|
+
})
|
|
28
|
+
.catch(done);
|
|
29
|
+
};
|
|
30
|
+
for (let index = 0; index < filepaths.length; index++) {
|
|
31
|
+
stream.write(index);
|
|
32
|
+
}
|
|
33
|
+
return stream;
|
|
34
|
+
}
|
|
35
|
+
#getEntry(filepath, pattern, options) {
|
|
36
|
+
return this.#getStat(filepath)
|
|
37
|
+
.then((stats) => this._makeEntry(stats, pattern))
|
|
38
|
+
.catch((error) => {
|
|
39
|
+
if (options.errorFilter(error)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
#getStat(filepath) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
|
48
|
+
if (error === null) {
|
|
49
|
+
resolve(stats);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
reject(error);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ReaderStream = ReaderStream;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as fsStat from '@nodelib/fs.stat';
|
|
2
|
+
import * as fsWalk from '@nodelib/fs.walk';
|
|
3
|
+
import { Reader } from './reader';
|
|
4
|
+
import type { Entry, Pattern, ReaderOptions } from '../types';
|
|
5
|
+
export interface IReaderSync {
|
|
6
|
+
dynamic: (root: string, options: ReaderOptions) => Entry[];
|
|
7
|
+
static: (patterns: Pattern[], options: ReaderOptions) => Entry[];
|
|
8
|
+
}
|
|
9
|
+
export declare class ReaderSync extends Reader<Entry[]> implements IReaderSync {
|
|
10
|
+
#private;
|
|
11
|
+
protected _walkSync: typeof fsWalk.walkSync;
|
|
12
|
+
protected _statSync: typeof fsStat.statSync;
|
|
13
|
+
dynamic(root: string, options: ReaderOptions): Entry[];
|
|
14
|
+
static(patterns: Pattern[], options: ReaderOptions): Entry[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReaderSync = void 0;
|
|
4
|
+
const fsStat = require("@nodelib/fs.stat");
|
|
5
|
+
const fsWalk = require("@nodelib/fs.walk");
|
|
6
|
+
const reader_1 = require("./reader");
|
|
7
|
+
class ReaderSync extends reader_1.Reader {
|
|
8
|
+
_walkSync = fsWalk.walkSync;
|
|
9
|
+
_statSync = fsStat.statSync;
|
|
10
|
+
dynamic(root, options) {
|
|
11
|
+
return this._walkSync(root, options);
|
|
12
|
+
}
|
|
13
|
+
static(patterns, options) {
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const pattern of patterns) {
|
|
16
|
+
const filepath = this._getFullEntryPath(pattern);
|
|
17
|
+
const entry = this.#getEntry(filepath, pattern, options);
|
|
18
|
+
if (entry === null || !options.entryFilter(entry)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
entries.push(entry);
|
|
22
|
+
}
|
|
23
|
+
return entries;
|
|
24
|
+
}
|
|
25
|
+
#getEntry(filepath, pattern, options) {
|
|
26
|
+
try {
|
|
27
|
+
const stats = this.#getStat(filepath);
|
|
28
|
+
return this._makeEntry(stats, pattern);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (options.errorFilter(error)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
#getStat(filepath) {
|
|
38
|
+
return this._statSync(filepath, this._fsStatSettings);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ReaderSync = ReaderSync;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { FileSystemAdapter, Pattern } from './types';
|
|
2
|
+
export declare const DEFAULT_FILE_SYSTEM_ADAPTER: FileSystemAdapter;
|
|
3
|
+
export interface Options {
|
|
4
|
+
/**
|
|
5
|
+
* Return the absolute path for entries.
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
absolute?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* If set to `true`, then patterns without slashes will be matched against
|
|
12
|
+
* the basename of the path if it contains slashes.
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
baseNameMatch?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enables Bash-like brace expansion.
|
|
19
|
+
*
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
braceExpansion?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enables a case-sensitive mode for matching files.
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
caseSensitiveMatch?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The current working directory in which to search.
|
|
31
|
+
*
|
|
32
|
+
* @default process.cwd()
|
|
33
|
+
*/
|
|
34
|
+
cwd?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the maximum depth of a read directory relative to the start
|
|
37
|
+
* directory.
|
|
38
|
+
*
|
|
39
|
+
* @default Infinity
|
|
40
|
+
*/
|
|
41
|
+
deep?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Allow patterns to match entries that begin with a period (`.`).
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
dot?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Enables Bash-like `extglob` functionality.
|
|
50
|
+
*
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
extglob?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Indicates whether to traverse descendants of symbolic link directories.
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
followSymbolicLinks?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Custom implementation of methods for working with the file system.
|
|
62
|
+
*
|
|
63
|
+
* @default fs.*
|
|
64
|
+
*/
|
|
65
|
+
fs?: Partial<FileSystemAdapter>;
|
|
66
|
+
/**
|
|
67
|
+
* Enables recursively repeats a pattern containing `**`.
|
|
68
|
+
* If `false`, `**` behaves exactly like `*`.
|
|
69
|
+
*
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
globstar?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* An array of glob patterns to exclude matches.
|
|
75
|
+
* This is an alternative way to use negative patterns.
|
|
76
|
+
*
|
|
77
|
+
* @default []
|
|
78
|
+
*/
|
|
79
|
+
ignore?: readonly Pattern[];
|
|
80
|
+
/**
|
|
81
|
+
* Mark the directory path with the final slash.
|
|
82
|
+
*
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
markDirectories?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Returns objects (instead of strings) describing entries.
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
objectMode?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Return only directories.
|
|
94
|
+
*
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
onlyDirectories?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Return only files.
|
|
100
|
+
*
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
onlyFiles?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Enables an object mode (`objectMode`) with an additional `stats` field.
|
|
106
|
+
*
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
stats?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* By default this package suppress only `ENOENT` errors.
|
|
112
|
+
* Set to `true` to suppress any error.
|
|
113
|
+
*
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
suppressErrors?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Throw an error when symbolic link is broken if `true` or safely
|
|
119
|
+
* return `lstat` call if `false`.
|
|
120
|
+
*
|
|
121
|
+
* @default false
|
|
122
|
+
*/
|
|
123
|
+
throwErrorOnBrokenSymbolicLink?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Ensures that the returned entries are unique.
|
|
126
|
+
*
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
129
|
+
unique?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* A signal to abort searching for entries on the file system.
|
|
132
|
+
* Works only with asynchronous methods for dynamic and static patterns.
|
|
133
|
+
*
|
|
134
|
+
* @default undefined
|
|
135
|
+
*/
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}
|
|
138
|
+
export default class Settings {
|
|
139
|
+
#private;
|
|
140
|
+
readonly absolute: boolean;
|
|
141
|
+
readonly baseNameMatch: boolean;
|
|
142
|
+
readonly braceExpansion: boolean;
|
|
143
|
+
readonly caseSensitiveMatch: boolean;
|
|
144
|
+
readonly cwd: string;
|
|
145
|
+
readonly deep: number;
|
|
146
|
+
readonly dot: boolean;
|
|
147
|
+
readonly extglob: boolean;
|
|
148
|
+
readonly followSymbolicLinks: boolean;
|
|
149
|
+
readonly fs: FileSystemAdapter;
|
|
150
|
+
readonly globstar: boolean;
|
|
151
|
+
readonly ignore: readonly Pattern[];
|
|
152
|
+
readonly markDirectories: boolean;
|
|
153
|
+
readonly objectMode: boolean;
|
|
154
|
+
readonly onlyDirectories: boolean;
|
|
155
|
+
readonly onlyFiles: boolean;
|
|
156
|
+
readonly stats: boolean;
|
|
157
|
+
readonly suppressErrors: boolean;
|
|
158
|
+
readonly throwErrorOnBrokenSymbolicLink: boolean;
|
|
159
|
+
readonly unique: boolean;
|
|
160
|
+
readonly signal?: AbortSignal;
|
|
161
|
+
constructor(options?: Options);
|
|
162
|
+
}
|