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

47 lines
2.0 KiB
Plaintext

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pluginName = void 0;
exports.getTsconfigWithContext = getTsconfigWithContext;
const node_path_1 = __importDefault(require("node:path"));
const get_tsconfig_1 = require("get-tsconfig");
const stable_hash_x_1 = require("stable-hash-x");
exports.pluginName = 'import-x';
const tsconfigCache = new Map();
function getTsconfigWithContext(context) {
var _a;
const parserOptions = ((_a = context.languageOptions) === null || _a === void 0 ? void 0 : _a.parserOptions) || context.parserOptions;
let tsconfigRootDir = parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.tsconfigRootDir;
const project = parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.project;
const cacheKey = (0, stable_hash_x_1.stableHash)([tsconfigRootDir, project]);
let tsconfig;
if (tsconfigCache.has(cacheKey)) {
tsconfig = tsconfigCache.get(cacheKey);
}
else {
tsconfigRootDir =
tsconfigRootDir ||
process.cwd();
let tsconfigResult;
if (project) {
const projects = Array.isArray(project) ? project : [project];
for (const project of projects) {
tsconfigResult = (0, get_tsconfig_1.getTsconfig)(project === true
? context.physicalFilename
: node_path_1.default.resolve(tsconfigRootDir, project));
if (tsconfigResult) {
break;
}
}
}
else {
tsconfigResult = (0, get_tsconfig_1.getTsconfig)(tsconfigRootDir);
}
tsconfig = tsconfigResult === null || tsconfigResult === void 0 ? void 0 : tsconfigResult.config;
tsconfigCache.set(cacheKey, tsconfig);
}
return tsconfig;
}
//# sourceMappingURL=utils.js.map