feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

92
node_modules/locate-path/index.js generated vendored
View File

@@ -1,65 +1,77 @@
'use strict';
const path = require('path');
const fs = require('fs');
const {promisify} = require('util');
const pLocate = require('p-locate');
const fsStat = promisify(fs.stat);
const fsLStat = promisify(fs.lstat);
import process from 'node:process';
import path from 'node:path';
import fs, {promises as fsPromises} from 'node:fs';
import {fileURLToPath} from 'node:url';
import pLocate from 'p-locate';
const typeMappings = {
directory: 'isDirectory',
file: 'isFile'
file: 'isFile',
};
function checkType({type}) {
if (type in typeMappings) {
function checkType(type) {
if (Object.hasOwnProperty.call(typeMappings, type)) {
return;
}
throw new Error(`Invalid type specified: ${type}`);
}
const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
const matchType = (type, stat) => stat[typeMappings[type]]();
module.exports = async (paths, options) => {
options = {
cwd: process.cwd(),
type: 'file',
allowSymlinks: true,
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fsStat : fsLStat;
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
export async function locatePath(
paths,
{
cwd = process.cwd(),
type = 'file',
allowSymlinks = true,
concurrency,
preserveOrder,
} = {},
) {
checkType(type);
cwd = toPath(cwd);
const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
return pLocate(paths, async path_ => {
try {
const stat = await statFn(path.resolve(options.cwd, path_));
return matchType(options.type, stat);
} catch (_) {
const stat = await statFunction(path.resolve(cwd, path_));
return matchType(type, stat);
} catch {
return false;
}
}, options);
};
}, {concurrency, preserveOrder});
}
module.exports.sync = (paths, options) => {
options = {
cwd: process.cwd(),
allowSymlinks: true,
type: 'file',
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fs.statSync : fs.lstatSync;
export function locatePathSync(
paths,
{
cwd = process.cwd(),
type = 'file',
allowSymlinks = true,
} = {},
) {
checkType(type);
cwd = toPath(cwd);
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
for (const path_ of paths) {
try {
const stat = statFn(path.resolve(options.cwd, path_));
const stat = statFunction(path.resolve(cwd, path_), {
throwIfNoEntry: false,
});
if (matchType(options.type, stat)) {
if (!stat) {
continue;
}
if (matchType(type, stat)) {
return path_;
}
} catch (_) {
}
} catch {}
}
};
}