🔧
This commit is contained in:
3
node_modules/fdir/dist/api/async.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Output, Options, ResultCallback } from "../types";
|
||||
export declare function promise<TOutput extends Output>(root: string, options: Options): Promise<TOutput>;
|
||||
export declare function callback<TOutput extends Output>(root: string, options: Options, callback: ResultCallback<TOutput>): void;
|
||||
19
node_modules/fdir/dist/api/async.js
generated
vendored
Normal file
19
node_modules/fdir/dist/api/async.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.callback = exports.promise = void 0;
|
||||
const walker_1 = require("./walker");
|
||||
function promise(root, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
callback(root, options, (err, output) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
resolve(output);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.promise = promise;
|
||||
function callback(root, options, callback) {
|
||||
let walker = new walker_1.Walker(root, options, callback);
|
||||
walker.start();
|
||||
}
|
||||
exports.callback = callback;
|
||||
12
node_modules/fdir/dist/api/counter.d.ts
generated
vendored
Normal file
12
node_modules/fdir/dist/api/counter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export declare class Counter {
|
||||
private _files;
|
||||
private _directories;
|
||||
set files(num: number);
|
||||
get files(): number;
|
||||
set directories(num: number);
|
||||
get directories(): number;
|
||||
/**
|
||||
* @deprecated use `directories` instead
|
||||
*/
|
||||
get dirs(): number;
|
||||
}
|
||||
27
node_modules/fdir/dist/api/counter.js
generated
vendored
Normal file
27
node_modules/fdir/dist/api/counter.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Counter = void 0;
|
||||
class Counter {
|
||||
_files = 0;
|
||||
_directories = 0;
|
||||
set files(num) {
|
||||
this._files = num;
|
||||
}
|
||||
get files() {
|
||||
return this._files;
|
||||
}
|
||||
set directories(num) {
|
||||
this._directories = num;
|
||||
}
|
||||
get directories() {
|
||||
return this._directories;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `directories` instead
|
||||
*/
|
||||
/* c8 ignore next 3 */
|
||||
get dirs() {
|
||||
return this._directories;
|
||||
}
|
||||
}
|
||||
exports.Counter = Counter;
|
||||
3
node_modules/fdir/dist/api/functions/get-array.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/functions/get-array.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Options } from "../../types";
|
||||
export type GetArrayFunction = (paths: string[]) => string[];
|
||||
export declare function build(options: Options): GetArrayFunction;
|
||||
13
node_modules/fdir/dist/api/functions/get-array.js
generated
vendored
Normal file
13
node_modules/fdir/dist/api/functions/get-array.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const getArray = (paths) => {
|
||||
return paths;
|
||||
};
|
||||
const getArrayGroup = () => {
|
||||
return [""].slice(0, 0);
|
||||
};
|
||||
function build(options) {
|
||||
return options.group ? getArrayGroup : getArray;
|
||||
}
|
||||
exports.build = build;
|
||||
3
node_modules/fdir/dist/api/functions/group-files.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/functions/group-files.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Group, Options } from "../../types";
|
||||
export type GroupFilesFunction = (groups: Group[], directory: string, files: string[]) => void;
|
||||
export declare function build(options: Options): GroupFilesFunction;
|
||||
11
node_modules/fdir/dist/api/functions/group-files.js
generated
vendored
Normal file
11
node_modules/fdir/dist/api/functions/group-files.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const groupFiles = (groups, directory, files) => {
|
||||
groups.push({ directory, files, dir: directory });
|
||||
};
|
||||
const empty = () => { };
|
||||
function build(options) {
|
||||
return options.group ? groupFiles : empty;
|
||||
}
|
||||
exports.build = build;
|
||||
3
node_modules/fdir/dist/api/functions/invoke-callback.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/functions/invoke-callback.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Output, ResultCallback, WalkerState, Options } from "../../types";
|
||||
export type InvokeCallbackFunction<TOutput extends Output> = (state: WalkerState, error: Error | null, callback?: ResultCallback<TOutput>) => null | TOutput;
|
||||
export declare function build<TOutput extends Output>(options: Options, isSynchronous: boolean): InvokeCallbackFunction<TOutput>;
|
||||
57
node_modules/fdir/dist/api/functions/invoke-callback.js
generated
vendored
Normal file
57
node_modules/fdir/dist/api/functions/invoke-callback.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const onlyCountsSync = (state) => {
|
||||
return state.counts;
|
||||
};
|
||||
const groupsSync = (state) => {
|
||||
return state.groups;
|
||||
};
|
||||
const defaultSync = (state) => {
|
||||
return state.paths;
|
||||
};
|
||||
const limitFilesSync = (state) => {
|
||||
return state.paths.slice(0, state.options.maxFiles);
|
||||
};
|
||||
const onlyCountsAsync = (state, error, callback) => {
|
||||
report(error, callback, state.counts, state.options.suppressErrors);
|
||||
return null;
|
||||
};
|
||||
const defaultAsync = (state, error, callback) => {
|
||||
report(error, callback, state.paths, state.options.suppressErrors);
|
||||
return null;
|
||||
};
|
||||
const limitFilesAsync = (state, error, callback) => {
|
||||
report(error, callback, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
||||
return null;
|
||||
};
|
||||
const groupsAsync = (state, error, callback) => {
|
||||
report(error, callback, state.groups, state.options.suppressErrors);
|
||||
return null;
|
||||
};
|
||||
function report(error, callback, output, suppressErrors) {
|
||||
if (error && !suppressErrors)
|
||||
callback(error, output);
|
||||
else
|
||||
callback(null, output);
|
||||
}
|
||||
function build(options, isSynchronous) {
|
||||
const { onlyCounts, group, maxFiles } = options;
|
||||
if (onlyCounts)
|
||||
return isSynchronous
|
||||
? onlyCountsSync
|
||||
: onlyCountsAsync;
|
||||
else if (group)
|
||||
return isSynchronous
|
||||
? groupsSync
|
||||
: groupsAsync;
|
||||
else if (maxFiles)
|
||||
return isSynchronous
|
||||
? limitFilesSync
|
||||
: limitFilesAsync;
|
||||
else
|
||||
return isSynchronous
|
||||
? defaultSync
|
||||
: defaultAsync;
|
||||
}
|
||||
exports.build = build;
|
||||
5
node_modules/fdir/dist/api/functions/is-recursive-symlink.d.ts
generated
vendored
Normal file
5
node_modules/fdir/dist/api/functions/is-recursive-symlink.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { WalkerState } from "../../types";
|
||||
type IsRecursiveSymlinkFunction = (state: WalkerState, path: string, resolved: string, callback: (result: boolean) => void) => void;
|
||||
export declare const isRecursiveAsync: IsRecursiveSymlinkFunction;
|
||||
export declare function isRecursive(state: WalkerState, path: string, resolved: string): boolean;
|
||||
export {};
|
||||
35
node_modules/fdir/dist/api/functions/is-recursive-symlink.js
generated
vendored
Normal file
35
node_modules/fdir/dist/api/functions/is-recursive-symlink.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isRecursive = exports.isRecursiveAsync = void 0;
|
||||
const path_1 = require("path");
|
||||
const fs_1 = require("fs");
|
||||
const isRecursiveAsync = (state, path, resolved, callback) => {
|
||||
if (state.options.useRealPaths)
|
||||
return callback(state.visited.has(resolved + state.options.pathSeparator));
|
||||
let parent = (0, path_1.dirname)(path);
|
||||
if (parent + state.options.pathSeparator === state.root || parent === path)
|
||||
return callback(false);
|
||||
if (state.symlinks.get(parent) === resolved)
|
||||
return callback(true);
|
||||
(0, fs_1.readlink)(parent, (error, resolvedParent) => {
|
||||
if (error)
|
||||
return (0, exports.isRecursiveAsync)(state, parent, resolved, callback);
|
||||
callback(resolvedParent === resolved);
|
||||
});
|
||||
};
|
||||
exports.isRecursiveAsync = isRecursiveAsync;
|
||||
function isRecursive(state, path, resolved) {
|
||||
if (state.options.useRealPaths)
|
||||
return state.visited.has(resolved + state.options.pathSeparator);
|
||||
let parent = (0, path_1.dirname)(path);
|
||||
if (parent + state.options.pathSeparator === state.root || parent === path)
|
||||
return false;
|
||||
try {
|
||||
const resolvedParent = state.symlinks.get(parent) || (0, fs_1.readlinkSync)(parent);
|
||||
return resolvedParent === resolved;
|
||||
}
|
||||
catch (e) {
|
||||
return isRecursive(state, parent, resolved);
|
||||
}
|
||||
}
|
||||
exports.isRecursive = isRecursive;
|
||||
5
node_modules/fdir/dist/api/functions/join-path.d.ts
generated
vendored
Normal file
5
node_modules/fdir/dist/api/functions/join-path.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Options, PathSeparator } from "../../types";
|
||||
export declare function joinPathWithBasePath(filename: string, directoryPath: string): string;
|
||||
export declare function joinDirectoryPath(filename: string, directoryPath: string, separator: PathSeparator): string;
|
||||
export type JoinPathFunction = (filename: string, directoryPath: string) => string;
|
||||
export declare function build(root: string, options: Options): JoinPathFunction;
|
||||
36
node_modules/fdir/dist/api/functions/join-path.js
generated
vendored
Normal file
36
node_modules/fdir/dist/api/functions/join-path.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = exports.joinDirectoryPath = exports.joinPathWithBasePath = void 0;
|
||||
const path_1 = require("path");
|
||||
const utils_1 = require("../../utils");
|
||||
function joinPathWithBasePath(filename, directoryPath) {
|
||||
return directoryPath + filename;
|
||||
}
|
||||
exports.joinPathWithBasePath = joinPathWithBasePath;
|
||||
function joinPathWithRelativePath(root, options) {
|
||||
return function (filename, directoryPath) {
|
||||
const sameRoot = directoryPath.startsWith(root);
|
||||
if (sameRoot)
|
||||
return directoryPath.replace(root, "") + filename;
|
||||
else
|
||||
return ((0, utils_1.convertSlashes)((0, path_1.relative)(root, directoryPath), options.pathSeparator) +
|
||||
options.pathSeparator +
|
||||
filename);
|
||||
};
|
||||
}
|
||||
function joinPath(filename) {
|
||||
return filename;
|
||||
}
|
||||
function joinDirectoryPath(filename, directoryPath, separator) {
|
||||
return directoryPath + filename + separator;
|
||||
}
|
||||
exports.joinDirectoryPath = joinDirectoryPath;
|
||||
function build(root, options) {
|
||||
const { relativePaths, includeBasePath } = options;
|
||||
return relativePaths && root
|
||||
? joinPathWithRelativePath(root, options)
|
||||
: includeBasePath
|
||||
? joinPathWithBasePath
|
||||
: joinPath;
|
||||
}
|
||||
exports.build = build;
|
||||
3
node_modules/fdir/dist/api/functions/push-directory.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/functions/push-directory.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { FilterPredicate, Options } from "../../types";
|
||||
export type PushDirectoryFunction = (directoryPath: string, paths: string[], filters?: FilterPredicate[]) => void;
|
||||
export declare function build(root: string, options: Options): PushDirectoryFunction;
|
||||
37
node_modules/fdir/dist/api/functions/push-directory.js
generated
vendored
Normal file
37
node_modules/fdir/dist/api/functions/push-directory.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
function pushDirectoryWithRelativePath(root) {
|
||||
return function (directoryPath, paths) {
|
||||
paths.push(directoryPath.substring(root.length) || ".");
|
||||
};
|
||||
}
|
||||
function pushDirectoryFilterWithRelativePath(root) {
|
||||
return function (directoryPath, paths, filters) {
|
||||
const relativePath = directoryPath.substring(root.length) || ".";
|
||||
if (filters.every((filter) => filter(relativePath, true))) {
|
||||
paths.push(relativePath);
|
||||
}
|
||||
};
|
||||
}
|
||||
const pushDirectory = (directoryPath, paths) => {
|
||||
paths.push(directoryPath || ".");
|
||||
};
|
||||
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
||||
const path = directoryPath || ".";
|
||||
if (filters.every((filter) => filter(path, true))) {
|
||||
paths.push(path);
|
||||
}
|
||||
};
|
||||
const empty = () => { };
|
||||
function build(root, options) {
|
||||
const { includeDirs, filters, relativePaths } = options;
|
||||
if (!includeDirs)
|
||||
return empty;
|
||||
if (relativePaths)
|
||||
return filters && filters.length
|
||||
? pushDirectoryFilterWithRelativePath(root)
|
||||
: pushDirectoryWithRelativePath(root);
|
||||
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
||||
}
|
||||
exports.build = build;
|
||||
3
node_modules/fdir/dist/api/functions/push-file.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/api/functions/push-file.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { FilterPredicate, Options, Counts } from "../../types";
|
||||
export type PushFileFunction = (directoryPath: string, paths: string[], counts: Counts, filters?: FilterPredicate[]) => void;
|
||||
export declare function build(options: Options): PushFileFunction;
|
||||
33
node_modules/fdir/dist/api/functions/push-file.js
generated
vendored
Normal file
33
node_modules/fdir/dist/api/functions/push-file.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
||||
if (filters.every((filter) => filter(filename, false)))
|
||||
counts.files++;
|
||||
};
|
||||
const pushFileFilter = (filename, paths, _counts, filters) => {
|
||||
if (filters.every((filter) => filter(filename, false)))
|
||||
paths.push(filename);
|
||||
};
|
||||
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
||||
counts.files++;
|
||||
};
|
||||
const pushFile = (filename, paths) => {
|
||||
paths.push(filename);
|
||||
};
|
||||
const empty = () => { };
|
||||
function build(options) {
|
||||
const { excludeFiles, filters, onlyCounts } = options;
|
||||
if (excludeFiles)
|
||||
return empty;
|
||||
if (filters && filters.length) {
|
||||
return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
||||
}
|
||||
else if (onlyCounts) {
|
||||
return pushFileCount;
|
||||
}
|
||||
else {
|
||||
return pushFile;
|
||||
}
|
||||
}
|
||||
exports.build = build;
|
||||
5
node_modules/fdir/dist/api/functions/resolve-symlink.d.ts
generated
vendored
Normal file
5
node_modules/fdir/dist/api/functions/resolve-symlink.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import fs from "fs";
|
||||
import { WalkerState, Options } from "../../types";
|
||||
export type ResolveSymlinkFunction = (path: string, state: WalkerState, callback: (stat: fs.Stats, path: string) => void) => void;
|
||||
export declare function build(options: Options, isSynchronous: boolean): ResolveSymlinkFunction | null;
|
||||
67
node_modules/fdir/dist/api/functions/resolve-symlink.js
generated
vendored
Normal file
67
node_modules/fdir/dist/api/functions/resolve-symlink.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = require("path");
|
||||
const resolveSymlinksAsync = function (path, state, callback) {
|
||||
const { queue, options: { suppressErrors }, } = state;
|
||||
queue.enqueue();
|
||||
fs_1.default.realpath(path, (error, resolvedPath) => {
|
||||
if (error)
|
||||
return queue.dequeue(suppressErrors ? null : error, state);
|
||||
fs_1.default.stat(resolvedPath, (error, stat) => {
|
||||
if (error)
|
||||
return queue.dequeue(suppressErrors ? null : error, state);
|
||||
if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
|
||||
return queue.dequeue(null, state);
|
||||
callback(stat, resolvedPath);
|
||||
queue.dequeue(null, state);
|
||||
});
|
||||
});
|
||||
};
|
||||
const resolveSymlinks = function (path, state, callback) {
|
||||
const { queue, options: { suppressErrors }, } = state;
|
||||
queue.enqueue();
|
||||
try {
|
||||
const resolvedPath = fs_1.default.realpathSync(path);
|
||||
const stat = fs_1.default.statSync(resolvedPath);
|
||||
if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
|
||||
return;
|
||||
callback(stat, resolvedPath);
|
||||
}
|
||||
catch (e) {
|
||||
if (!suppressErrors)
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
function build(options, isSynchronous) {
|
||||
if (!options.resolveSymlinks || options.excludeSymlinks)
|
||||
return null;
|
||||
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
||||
}
|
||||
exports.build = build;
|
||||
function isRecursive(path, resolved, state) {
|
||||
if (state.options.useRealPaths)
|
||||
return isRecursiveUsingRealPaths(resolved, state);
|
||||
let parent = (0, path_1.dirname)(path);
|
||||
let depth = 1;
|
||||
while (parent !== state.root && depth < 2) {
|
||||
const resolvedPath = state.symlinks.get(parent);
|
||||
const isSameRoot = !!resolvedPath &&
|
||||
(resolvedPath === resolved ||
|
||||
resolvedPath.startsWith(resolved) ||
|
||||
resolved.startsWith(resolvedPath));
|
||||
if (isSameRoot)
|
||||
depth++;
|
||||
else
|
||||
parent = (0, path_1.dirname)(parent);
|
||||
}
|
||||
state.symlinks.set(path, resolved);
|
||||
return depth > 1;
|
||||
}
|
||||
function isRecursiveUsingRealPaths(resolved, state) {
|
||||
return state.visited.includes(resolved + state.options.pathSeparator);
|
||||
}
|
||||
5
node_modules/fdir/dist/api/functions/walk-directory.d.ts
generated
vendored
Normal file
5
node_modules/fdir/dist/api/functions/walk-directory.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import { WalkerState } from "../../types";
|
||||
import fs from "fs";
|
||||
export type WalkDirectoryFunction = (state: WalkerState, crawlPath: string, directoryPath: string, depth: number, callback: (entries: fs.Dirent[], directoryPath: string, depth: number) => void) => void;
|
||||
export declare function build(isSynchronous: boolean): WalkDirectoryFunction;
|
||||
40
node_modules/fdir/dist/api/functions/walk-directory.js
generated
vendored
Normal file
40
node_modules/fdir/dist/api/functions/walk-directory.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const readdirOpts = { withFileTypes: true };
|
||||
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
|
||||
if (currentDepth < 0)
|
||||
return state.queue.dequeue(null, state);
|
||||
state.visited.push(crawlPath);
|
||||
state.counts.directories++;
|
||||
state.queue.enqueue();
|
||||
// Perf: Node >= 10 introduced withFileTypes that helps us
|
||||
// skip an extra fs.stat call.
|
||||
fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
||||
callback(entries, directoryPath, currentDepth);
|
||||
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
||||
});
|
||||
};
|
||||
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
|
||||
if (currentDepth < 0)
|
||||
return;
|
||||
state.visited.push(crawlPath);
|
||||
state.counts.directories++;
|
||||
let entries = [];
|
||||
try {
|
||||
entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
|
||||
}
|
||||
catch (e) {
|
||||
if (!state.options.suppressErrors)
|
||||
throw e;
|
||||
}
|
||||
callback(entries, directoryPath, currentDepth);
|
||||
};
|
||||
function build(isSynchronous) {
|
||||
return isSynchronous ? walkSync : walkAsync;
|
||||
}
|
||||
exports.build = build;
|
||||
15
node_modules/fdir/dist/api/queue.d.ts
generated
vendored
Normal file
15
node_modules/fdir/dist/api/queue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { WalkerState } from "../types";
|
||||
type OnQueueEmptyCallback = (error: Error | null, output: WalkerState) => void;
|
||||
/**
|
||||
* This is a custom stateless queue to track concurrent async fs calls.
|
||||
* It increments a counter whenever a call is queued and decrements it
|
||||
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
||||
*/
|
||||
export declare class Queue {
|
||||
private readonly onQueueEmpty;
|
||||
private count;
|
||||
constructor(onQueueEmpty: OnQueueEmptyCallback);
|
||||
enqueue(): void;
|
||||
dequeue(error: Error | null, output: WalkerState): void;
|
||||
}
|
||||
export {};
|
||||
23
node_modules/fdir/dist/api/queue.js
generated
vendored
Normal file
23
node_modules/fdir/dist/api/queue.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Queue = void 0;
|
||||
/**
|
||||
* This is a custom stateless queue to track concurrent async fs calls.
|
||||
* It increments a counter whenever a call is queued and decrements it
|
||||
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
||||
*/
|
||||
class Queue {
|
||||
onQueueEmpty;
|
||||
count = 0;
|
||||
constructor(onQueueEmpty) {
|
||||
this.onQueueEmpty = onQueueEmpty;
|
||||
}
|
||||
enqueue() {
|
||||
this.count++;
|
||||
}
|
||||
dequeue(error, output) {
|
||||
if (--this.count <= 0 || error)
|
||||
this.onQueueEmpty(error, output);
|
||||
}
|
||||
}
|
||||
exports.Queue = Queue;
|
||||
2
node_modules/fdir/dist/api/sync.d.ts
generated
vendored
Normal file
2
node_modules/fdir/dist/api/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Output, Options } from "../types";
|
||||
export declare function sync<TOutput extends Output>(root: string, options: Options): TOutput;
|
||||
9
node_modules/fdir/dist/api/sync.js
generated
vendored
Normal file
9
node_modules/fdir/dist/api/sync.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sync = void 0;
|
||||
const walker_1 = require("./walker");
|
||||
function sync(root, options) {
|
||||
const walker = new walker_1.Walker(root, options);
|
||||
return walker.start();
|
||||
}
|
||||
exports.sync = sync;
|
||||
18
node_modules/fdir/dist/api/walker.d.ts
generated
vendored
Normal file
18
node_modules/fdir/dist/api/walker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ResultCallback, Options } from "../types";
|
||||
import { Output } from "../types";
|
||||
export declare class Walker<TOutput extends Output> {
|
||||
private readonly root;
|
||||
private readonly isSynchronous;
|
||||
private readonly state;
|
||||
private readonly joinPath;
|
||||
private readonly pushDirectory;
|
||||
private readonly pushFile;
|
||||
private readonly getArray;
|
||||
private readonly groupFiles;
|
||||
private readonly resolveSymlink;
|
||||
private readonly walkDirectory;
|
||||
private readonly callbackInvoker;
|
||||
constructor(root: string, options: Options, callback?: ResultCallback<TOutput>);
|
||||
start(): TOutput | null;
|
||||
private walk;
|
||||
}
|
||||
124
node_modules/fdir/dist/api/walker.js
generated
vendored
Normal file
124
node_modules/fdir/dist/api/walker.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Walker = void 0;
|
||||
const path_1 = require("path");
|
||||
const utils_1 = require("../utils");
|
||||
const joinPath = __importStar(require("./functions/join-path"));
|
||||
const pushDirectory = __importStar(require("./functions/push-directory"));
|
||||
const pushFile = __importStar(require("./functions/push-file"));
|
||||
const getArray = __importStar(require("./functions/get-array"));
|
||||
const groupFiles = __importStar(require("./functions/group-files"));
|
||||
const resolveSymlink = __importStar(require("./functions/resolve-symlink"));
|
||||
const invokeCallback = __importStar(require("./functions/invoke-callback"));
|
||||
const walkDirectory = __importStar(require("./functions/walk-directory"));
|
||||
const queue_1 = require("./queue");
|
||||
const counter_1 = require("./counter");
|
||||
class Walker {
|
||||
root;
|
||||
isSynchronous;
|
||||
state;
|
||||
joinPath;
|
||||
pushDirectory;
|
||||
pushFile;
|
||||
getArray;
|
||||
groupFiles;
|
||||
resolveSymlink;
|
||||
walkDirectory;
|
||||
callbackInvoker;
|
||||
constructor(root, options, callback) {
|
||||
this.isSynchronous = !callback;
|
||||
this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
|
||||
this.root = (0, utils_1.normalizePath)(root, options);
|
||||
this.state = {
|
||||
root: this.root.slice(0, -1),
|
||||
// Perf: we explicitly tell the compiler to optimize for String arrays
|
||||
paths: [""].slice(0, 0),
|
||||
groups: [],
|
||||
counts: new counter_1.Counter(),
|
||||
options,
|
||||
queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
|
||||
symlinks: new Map(),
|
||||
visited: [""].slice(0, 0),
|
||||
};
|
||||
/*
|
||||
* Perf: We conditionally change functions according to options. This gives a slight
|
||||
* performance boost. Since these functions are so small, they are automatically inlined
|
||||
* by the javascript engine so there's no function call overhead (in most cases).
|
||||
*/
|
||||
this.joinPath = joinPath.build(this.root, options);
|
||||
this.pushDirectory = pushDirectory.build(this.root, options);
|
||||
this.pushFile = pushFile.build(options);
|
||||
this.getArray = getArray.build(options);
|
||||
this.groupFiles = groupFiles.build(options);
|
||||
this.resolveSymlink = resolveSymlink.build(options, this.isSynchronous);
|
||||
this.walkDirectory = walkDirectory.build(this.isSynchronous);
|
||||
}
|
||||
start() {
|
||||
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
||||
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
||||
}
|
||||
walk = (entries, directoryPath, depth) => {
|
||||
const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;
|
||||
if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
|
||||
return;
|
||||
this.pushDirectory(directoryPath, paths, filters);
|
||||
const files = this.getArray(this.state.paths);
|
||||
for (let i = 0; i < entries.length; ++i) {
|
||||
const entry = entries[i];
|
||||
if (entry.isFile() ||
|
||||
(entry.isSymbolicLink() && !resolveSymlinks && !excludeSymlinks)) {
|
||||
const filename = this.joinPath(entry.name, directoryPath);
|
||||
this.pushFile(filename, files, this.state.counts, filters);
|
||||
}
|
||||
else if (entry.isDirectory()) {
|
||||
let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
||||
if (exclude && exclude(entry.name, path))
|
||||
continue;
|
||||
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
||||
}
|
||||
else if (entry.isSymbolicLink() && this.resolveSymlink) {
|
||||
let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
|
||||
this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
|
||||
if (stat.isDirectory()) {
|
||||
resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
|
||||
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator))
|
||||
return;
|
||||
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
||||
}
|
||||
else {
|
||||
resolvedPath = useRealPaths ? resolvedPath : path;
|
||||
const filename = (0, path_1.basename)(resolvedPath);
|
||||
const directoryPath = (0, utils_1.normalizePath)((0, path_1.dirname)(resolvedPath), this.state.options);
|
||||
resolvedPath = this.joinPath(filename, directoryPath);
|
||||
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
this.groupFiles(this.state.groups, directoryPath, files);
|
||||
};
|
||||
}
|
||||
exports.Walker = Walker;
|
||||
9
node_modules/fdir/dist/builder/api-builder.d.ts
generated
vendored
Normal file
9
node_modules/fdir/dist/builder/api-builder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Options, Output, ResultCallback } from "../types";
|
||||
export declare class APIBuilder<TReturnType extends Output> {
|
||||
private readonly root;
|
||||
private readonly options;
|
||||
constructor(root: string, options: Options);
|
||||
withPromise(): Promise<TReturnType>;
|
||||
withCallback(cb: ResultCallback<TReturnType>): void;
|
||||
sync(): TReturnType;
|
||||
}
|
||||
23
node_modules/fdir/dist/builder/api-builder.js
generated
vendored
Normal file
23
node_modules/fdir/dist/builder/api-builder.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.APIBuilder = void 0;
|
||||
const async_1 = require("../api/async");
|
||||
const sync_1 = require("../api/sync");
|
||||
class APIBuilder {
|
||||
root;
|
||||
options;
|
||||
constructor(root, options) {
|
||||
this.root = root;
|
||||
this.options = options;
|
||||
}
|
||||
withPromise() {
|
||||
return (0, async_1.promise)(this.root, this.options);
|
||||
}
|
||||
withCallback(cb) {
|
||||
(0, async_1.callback)(this.root, this.options, cb);
|
||||
}
|
||||
sync() {
|
||||
return (0, sync_1.sync)(this.root, this.options);
|
||||
}
|
||||
}
|
||||
exports.APIBuilder = APIBuilder;
|
||||
41
node_modules/fdir/dist/builder/index.d.ts
generated
vendored
Normal file
41
node_modules/fdir/dist/builder/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/// <reference types="node" />
|
||||
import { Output, OnlyCountsOutput, GroupOutput, PathsOutput, Options, FilterPredicate, ExcludePredicate, GlobParams } from "../types";
|
||||
import { APIBuilder } from "./api-builder";
|
||||
import type picomatch from "picomatch";
|
||||
export declare class Builder<TReturnType extends Output = PathsOutput, TGlobFunction = typeof picomatch> {
|
||||
private readonly globCache;
|
||||
private options;
|
||||
private globFunction?;
|
||||
constructor(options?: Partial<Options<TGlobFunction>>);
|
||||
group(): Builder<GroupOutput, TGlobFunction>;
|
||||
withPathSeparator(separator: "/" | "\\"): this;
|
||||
withBasePath(): this;
|
||||
withRelativePaths(): this;
|
||||
withDirs(): this;
|
||||
withMaxDepth(depth: number): this;
|
||||
withMaxFiles(limit: number): this;
|
||||
withFullPaths(): this;
|
||||
withErrors(): this;
|
||||
withSymlinks({ resolvePaths }?: {
|
||||
resolvePaths?: boolean | undefined;
|
||||
}): this;
|
||||
withAbortSignal(signal: AbortSignal): this;
|
||||
normalize(): this;
|
||||
filter(predicate: FilterPredicate): this;
|
||||
onlyDirs(): this;
|
||||
exclude(predicate: ExcludePredicate): this;
|
||||
onlyCounts(): Builder<OnlyCountsOutput, TGlobFunction>;
|
||||
crawl(root?: string): APIBuilder<TReturnType>;
|
||||
withGlobFunction<TFunc>(fn: TFunc): Builder<TReturnType, TFunc>;
|
||||
/**
|
||||
* @deprecated Pass options using the constructor instead:
|
||||
* ```ts
|
||||
* new fdir(options).crawl("/path/to/root");
|
||||
* ```
|
||||
* This method will be removed in v7.0
|
||||
*/
|
||||
crawlWithOptions(root: string, options: Partial<Options<TGlobFunction>>): APIBuilder<TReturnType>;
|
||||
glob(...patterns: string[]): Builder<TReturnType, TGlobFunction>;
|
||||
globWithOptions(patterns: string[]): Builder<TReturnType, TGlobFunction>;
|
||||
globWithOptions(patterns: string[], ...options: GlobParams<TGlobFunction>): Builder<TReturnType, TGlobFunction>;
|
||||
}
|
||||
136
node_modules/fdir/dist/builder/index.js
generated
vendored
Normal file
136
node_modules/fdir/dist/builder/index.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Builder = void 0;
|
||||
const path_1 = require("path");
|
||||
const api_builder_1 = require("./api-builder");
|
||||
var pm = null;
|
||||
/* c8 ignore next 6 */
|
||||
try {
|
||||
require.resolve("picomatch");
|
||||
pm = require("picomatch");
|
||||
}
|
||||
catch (_e) {
|
||||
// do nothing
|
||||
}
|
||||
class Builder {
|
||||
globCache = {};
|
||||
options = {
|
||||
maxDepth: Infinity,
|
||||
suppressErrors: true,
|
||||
pathSeparator: path_1.sep,
|
||||
filters: [],
|
||||
};
|
||||
globFunction;
|
||||
constructor(options) {
|
||||
this.options = { ...this.options, ...options };
|
||||
this.globFunction = this.options.globFunction;
|
||||
}
|
||||
group() {
|
||||
this.options.group = true;
|
||||
return this;
|
||||
}
|
||||
withPathSeparator(separator) {
|
||||
this.options.pathSeparator = separator;
|
||||
return this;
|
||||
}
|
||||
withBasePath() {
|
||||
this.options.includeBasePath = true;
|
||||
return this;
|
||||
}
|
||||
withRelativePaths() {
|
||||
this.options.relativePaths = true;
|
||||
return this;
|
||||
}
|
||||
withDirs() {
|
||||
this.options.includeDirs = true;
|
||||
return this;
|
||||
}
|
||||
withMaxDepth(depth) {
|
||||
this.options.maxDepth = depth;
|
||||
return this;
|
||||
}
|
||||
withMaxFiles(limit) {
|
||||
this.options.maxFiles = limit;
|
||||
return this;
|
||||
}
|
||||
withFullPaths() {
|
||||
this.options.resolvePaths = true;
|
||||
this.options.includeBasePath = true;
|
||||
return this;
|
||||
}
|
||||
withErrors() {
|
||||
this.options.suppressErrors = false;
|
||||
return this;
|
||||
}
|
||||
withSymlinks({ resolvePaths = true } = {}) {
|
||||
this.options.resolveSymlinks = true;
|
||||
this.options.useRealPaths = resolvePaths;
|
||||
return this.withFullPaths();
|
||||
}
|
||||
withAbortSignal(signal) {
|
||||
this.options.signal = signal;
|
||||
return this;
|
||||
}
|
||||
normalize() {
|
||||
this.options.normalizePath = true;
|
||||
return this;
|
||||
}
|
||||
filter(predicate) {
|
||||
this.options.filters.push(predicate);
|
||||
return this;
|
||||
}
|
||||
onlyDirs() {
|
||||
this.options.excludeFiles = true;
|
||||
this.options.includeDirs = true;
|
||||
return this;
|
||||
}
|
||||
exclude(predicate) {
|
||||
this.options.exclude = predicate;
|
||||
return this;
|
||||
}
|
||||
onlyCounts() {
|
||||
this.options.onlyCounts = true;
|
||||
return this;
|
||||
}
|
||||
crawl(root) {
|
||||
return new api_builder_1.APIBuilder(root || ".", this.options);
|
||||
}
|
||||
withGlobFunction(fn) {
|
||||
// cast this since we don't have the new type params yet
|
||||
this.globFunction = fn;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @deprecated Pass options using the constructor instead:
|
||||
* ```ts
|
||||
* new fdir(options).crawl("/path/to/root");
|
||||
* ```
|
||||
* This method will be removed in v7.0
|
||||
*/
|
||||
/* c8 ignore next 4 */
|
||||
crawlWithOptions(root, options) {
|
||||
this.options = { ...this.options, ...options };
|
||||
return new api_builder_1.APIBuilder(root || ".", this.options);
|
||||
}
|
||||
glob(...patterns) {
|
||||
if (this.globFunction) {
|
||||
return this.globWithOptions(patterns);
|
||||
}
|
||||
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
||||
}
|
||||
globWithOptions(patterns, ...options) {
|
||||
const globFn = (this.globFunction || pm);
|
||||
/* c8 ignore next 5 */
|
||||
if (!globFn) {
|
||||
throw new Error('Please specify a glob function to use glob matching.');
|
||||
}
|
||||
var isMatch = this.globCache[patterns.join("\0")];
|
||||
if (!isMatch) {
|
||||
isMatch = globFn(patterns, ...options);
|
||||
this.globCache[patterns.join("\0")] = isMatch;
|
||||
}
|
||||
this.options.filters.push((path) => isMatch(path));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
exports.Builder = Builder;
|
||||
4
node_modules/fdir/dist/index.d.ts
generated
vendored
Normal file
4
node_modules/fdir/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Builder } from "./builder";
|
||||
export { Builder as fdir };
|
||||
export type Fdir = typeof Builder;
|
||||
export * from "./types";
|
||||
20
node_modules/fdir/dist/index.js
generated
vendored
Normal file
20
node_modules/fdir/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fdir = void 0;
|
||||
const builder_1 = require("./builder");
|
||||
Object.defineProperty(exports, "fdir", { enumerable: true, get: function () { return builder_1.Builder; } });
|
||||
__exportStar(require("./types"), exports);
|
||||
3
node_modules/fdir/dist/optimizer.d.ts
generated
vendored
Normal file
3
node_modules/fdir/dist/optimizer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function findCommonRoots(patterns: string[]): string[];
|
||||
export declare function findDirectoryPatterns(patterns: string[]): string[];
|
||||
export declare function findMaxDepth(patterns: string[]): number | false;
|
||||
54
node_modules/fdir/dist/optimizer.js
generated
vendored
Normal file
54
node_modules/fdir/dist/optimizer.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findMaxDepth = exports.findDirectoryPatterns = exports.findCommonRoots = void 0;
|
||||
// Glob Optimizations:
|
||||
// 1. Find common roots and only iterate on them
|
||||
// For example:
|
||||
// 1. "node_modules/**/*.ts" only requires us to search in node_modules
|
||||
// folder.
|
||||
// 2. Similarly, multiple glob patterns can have common deterministic roots
|
||||
// The optimizer's job is to find these roots and only crawl them.
|
||||
// 3. If any of the glob patterns have a globstar i.e. **/ in them, we
|
||||
// should bail out.
|
||||
// 2. Find out if glob is requesting only directories
|
||||
// 3. Find maximum depth requested
|
||||
// 4. If glob contains a root that doesn't exist, bail out
|
||||
const braces_1 = require("braces");
|
||||
const glob_parent_1 = __importDefault(require("glob-parent"));
|
||||
function findCommonRoots(patterns) {
|
||||
const allRoots = new Set();
|
||||
patterns = patterns.map((p) => (p.includes("{") ? (0, braces_1.expand)(p) : p)).flat();
|
||||
for (const pattern of patterns) {
|
||||
const parent = (0, glob_parent_1.default)(pattern);
|
||||
if (parent === ".")
|
||||
return [];
|
||||
allRoots.add(parent);
|
||||
}
|
||||
return Array.from(allRoots.values()).filter((root) => {
|
||||
for (const r of allRoots) {
|
||||
if (r === root)
|
||||
continue;
|
||||
if (root.startsWith(r))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
exports.findCommonRoots = findCommonRoots;
|
||||
function findDirectoryPatterns(patterns) {
|
||||
return patterns.filter((p) => p.endsWith("/"));
|
||||
}
|
||||
exports.findDirectoryPatterns = findDirectoryPatterns;
|
||||
function findMaxDepth(patterns) {
|
||||
const isGlobstar = patterns.some((p) => p.includes("**/") || p.includes("/**") || p === "**");
|
||||
if (isGlobstar)
|
||||
return false;
|
||||
const maxDepth = patterns.reduce((depth, p) => {
|
||||
return Math.max(depth, p.split("/").filter(Boolean).length);
|
||||
}, 0);
|
||||
return maxDepth;
|
||||
}
|
||||
exports.findMaxDepth = findMaxDepth;
|
||||
60
node_modules/fdir/dist/types.d.ts
generated
vendored
Normal file
60
node_modules/fdir/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/// <reference types="node" />
|
||||
import { Queue } from "./api/queue";
|
||||
export type Counts = {
|
||||
files: number;
|
||||
directories: number;
|
||||
/**
|
||||
* @deprecated use `directories` instead. Will be removed in v7.0.
|
||||
*/
|
||||
dirs: number;
|
||||
};
|
||||
export type Group = {
|
||||
directory: string;
|
||||
files: string[];
|
||||
/**
|
||||
* @deprecated use `directory` instead. Will be removed in v7.0.
|
||||
*/
|
||||
dir: string;
|
||||
};
|
||||
export type GroupOutput = Group[];
|
||||
export type OnlyCountsOutput = Counts;
|
||||
export type PathsOutput = string[];
|
||||
export type Output = OnlyCountsOutput | PathsOutput | GroupOutput;
|
||||
export type WalkerState = {
|
||||
root: string;
|
||||
paths: string[];
|
||||
groups: Group[];
|
||||
counts: Counts;
|
||||
options: Options;
|
||||
queue: Queue;
|
||||
symlinks: Map<string, string>;
|
||||
visited: string[];
|
||||
};
|
||||
export type ResultCallback<TOutput extends Output> = (error: Error | null, output: TOutput) => void;
|
||||
export type FilterPredicate = (path: string, isDirectory: boolean) => boolean;
|
||||
export type ExcludePredicate = (dirName: string, dirPath: string) => boolean;
|
||||
export type PathSeparator = "/" | "\\";
|
||||
export type Options<TGlobFunction = unknown> = {
|
||||
includeBasePath?: boolean;
|
||||
includeDirs?: boolean;
|
||||
normalizePath?: boolean;
|
||||
maxDepth: number;
|
||||
maxFiles?: number;
|
||||
resolvePaths?: boolean;
|
||||
suppressErrors: boolean;
|
||||
group?: boolean;
|
||||
onlyCounts?: boolean;
|
||||
filters: FilterPredicate[];
|
||||
resolveSymlinks?: boolean;
|
||||
useRealPaths?: boolean;
|
||||
excludeFiles?: boolean;
|
||||
excludeSymlinks?: boolean;
|
||||
exclude?: ExcludePredicate;
|
||||
relativePaths?: boolean;
|
||||
pathSeparator: PathSeparator;
|
||||
signal?: AbortSignal;
|
||||
globFunction?: TGlobFunction;
|
||||
};
|
||||
export type GlobMatcher = (test: string) => boolean;
|
||||
export type GlobFunction = (glob: string | string[], ...params: unknown[]) => GlobMatcher;
|
||||
export type GlobParams<T> = T extends (globs: string | string[], ...params: infer TParams extends unknown[]) => GlobMatcher ? TParams : [];
|
||||
2
node_modules/fdir/dist/types.js
generated
vendored
Normal file
2
node_modules/fdir/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
8
node_modules/fdir/dist/utils.d.ts
generated
vendored
Normal file
8
node_modules/fdir/dist/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { PathSeparator } from "./types";
|
||||
export declare function cleanPath(path: string): string;
|
||||
export declare function convertSlashes(path: string, separator: PathSeparator): string;
|
||||
export declare function normalizePath(path: string, options: {
|
||||
resolvePaths?: boolean;
|
||||
normalizePath?: boolean;
|
||||
pathSeparator: PathSeparator;
|
||||
}): string;
|
||||
32
node_modules/fdir/dist/utils.js
generated
vendored
Normal file
32
node_modules/fdir/dist/utils.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizePath = exports.convertSlashes = exports.cleanPath = void 0;
|
||||
const path_1 = require("path");
|
||||
function cleanPath(path) {
|
||||
let normalized = (0, path_1.normalize)(path);
|
||||
// we have to remove the last path separator
|
||||
// to account for / root path
|
||||
if (normalized.length > 1 && normalized[normalized.length - 1] === path_1.sep)
|
||||
normalized = normalized.substring(0, normalized.length - 1);
|
||||
return normalized;
|
||||
}
|
||||
exports.cleanPath = cleanPath;
|
||||
const SLASHES_REGEX = /[\\/]/g;
|
||||
function convertSlashes(path, separator) {
|
||||
return path.replace(SLASHES_REGEX, separator);
|
||||
}
|
||||
exports.convertSlashes = convertSlashes;
|
||||
function normalizePath(path, options) {
|
||||
const { resolvePaths, normalizePath, pathSeparator } = options;
|
||||
const pathNeedsCleaning = (process.platform === "win32" && path.includes("/")) ||
|
||||
path.startsWith(".");
|
||||
if (resolvePaths)
|
||||
path = (0, path_1.resolve)(path);
|
||||
if (normalizePath || pathNeedsCleaning)
|
||||
path = cleanPath(path);
|
||||
if (path === ".")
|
||||
return "";
|
||||
const needsSeperator = path[path.length - 1] !== pathSeparator;
|
||||
return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
|
||||
}
|
||||
exports.normalizePath = normalizePath;
|
||||
Reference in New Issue
Block a user