Files
NapCatQQ/.pnpm-store/v3/files/ce/011bff3248d7028cbcc8a1d8c8045af62a0e5acb29b5afdc6461f28487557f2b31e89e1becc5d4c2d614ccb2fbe2dfb2bd90796059ebd7636dfbdb36b417e0
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

73 lines
3.1 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findBasePathOfAlias = exports.relativeOutPathToConfigDir = void 0;
const normalizePath = require("normalize-path");
const globby_1 = require("globby");
const path_1 = require("path");
function getProjectDirPathInOutDir(outDir, projectDir) {
const posixOutput = outDir.replace(/\\/g, '/');
const dirs = (0, globby_1.sync)([
`${posixOutput}/**/${projectDir}`,
`!${posixOutput}/**/${projectDir}/**/${projectDir}`,
`!${posixOutput}/**/node_modules`
], {
dot: true,
onlyDirectories: true
});
return dirs.reduce((prev, curr) => prev.split('/').length > curr.split('/').length ? prev : curr, dirs[0]);
}
function relativeOutPathToConfigDir(config) {
config.configDirInOutPath = getProjectDirPathInOutDir(config.outPath, config.confDirParentFolderName);
if (config.configDirInOutPath) {
config.hasExtraModule = true;
const stepsbackPath = (0, path_1.relative)(config.configDirInOutPath, config.outPath);
const splitStepBackPath = normalizePath(stepsbackPath).split('/');
const nbOfStepBack = splitStepBackPath.length;
const splitConfDirInOutPath = config.configDirInOutPath.split('/');
let i = 1;
const splitRelPath = [];
while (i <= nbOfStepBack) {
splitRelPath.unshift(splitConfDirInOutPath[splitConfDirInOutPath.length - i]);
i++;
}
config.relConfDirPathInOutPath = splitRelPath.join('/');
}
}
exports.relativeOutPathToConfigDir = relativeOutPathToConfigDir;
function findBasePathOfAlias(config) {
return (path) => {
const aliasPath = { path };
if ((0, path_1.normalize)(aliasPath.path).includes('..')) {
const tempBasePath = normalizePath((0, path_1.normalize)(`${config.outDir}/` +
`${config.hasExtraModule && config.relConfDirPathInOutPath
? config.relConfDirPathInOutPath
: ''}/${config.baseUrl}`));
const absoluteBasePath = normalizePath((0, path_1.normalize)(`${tempBasePath}/${aliasPath.path}`));
if (config.pathCache.existsResolvedAlias(absoluteBasePath)) {
aliasPath.isExtra = false;
aliasPath.basePath = tempBasePath;
}
else {
aliasPath.isExtra = true;
aliasPath.basePath = absoluteBasePath;
}
return aliasPath;
}
if (aliasPath.path.match(/^(\.\/|)node_modules/g)) {
aliasPath.basePath = (0, path_1.resolve)(config.baseUrl, 'node_modules');
aliasPath.isExtra = false;
return aliasPath;
}
if (config.hasExtraModule) {
aliasPath.isExtra = false;
aliasPath.basePath = normalizePath((0, path_1.normalize)(`${config.outDir}/` +
`${config.relConfDirPathInOutPath}/${config.baseUrl}`));
return aliasPath;
}
aliasPath.basePath = config.outDir;
aliasPath.isExtra = false;
return aliasPath;
};
}
exports.findBasePathOfAlias = findBasePathOfAlias;
//# sourceMappingURL=path.js.map