full site update
This commit is contained in:
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;
|
Reference in New Issue
Block a user