full site update
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/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) => {
|
||||
state.queue.enqueue();
|
||||
if (currentDepth < 0)
|
||||
return state.queue.dequeue(null, state);
|
||||
state.visited.push(crawlPath);
|
||||
state.counts.directories++;
|
||||
// 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 onQueueEmpty?;
|
||||
count: number;
|
||||
constructor(onQueueEmpty?: OnQueueEmptyCallback | undefined);
|
||||
enqueue(): number;
|
||||
dequeue(error: Error | null, output: WalkerState): void;
|
||||
}
|
||||
export {};
|
29
node_modules/fdir/dist/api/queue.js
generated
vendored
Normal file
29
node_modules/fdir/dist/api/queue.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"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++;
|
||||
return this.count;
|
||||
}
|
||||
dequeue(error, output) {
|
||||
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
||||
this.onQueueEmpty(error, output);
|
||||
if (error) {
|
||||
output.controller.abort();
|
||||
this.onQueueEmpty = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
129
node_modules/fdir/dist/api/walker.js
generated
vendored
Normal file
129
node_modules/fdir/dist/api/walker.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
"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: (0, utils_1.isRootDirectory)(this.root) ? this.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),
|
||||
controller: new AbortController(),
|
||||
};
|
||||
/*
|
||||
* 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.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
||||
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, }, controller, } = this.state;
|
||||
if (controller.signal.aborted ||
|
||||
(signal && signal.aborted) ||
|
||||
(maxFiles && paths.length > maxFiles))
|
||||
return;
|
||||
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.pushDirectory(path, paths, filters);
|
||||
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
||||
}
|
||||
else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
||||
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;
|
Reference in New Issue
Block a user