sveldoc
Version:
Readme-driven Development for building Svelte components
27 lines (26 loc) • 1.22 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTsconfigPaths = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const getTsconfigPaths = () => {
var _a, _b, _c;
let tsconfig = {};
try {
const tsconfig_path = node_path_1.default.join(process.cwd(), "tsconfig.json");
const tsconfig_json = node_fs_1.default.readFileSync(tsconfig_path, "utf-8");
tsconfig = (_a = JSON.parse(tsconfig_json)) !== null && _a !== void 0 ? _a : {};
}
catch (e) {
}
finally {
const tsconfig_paths = (_c = (_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {};
return Object.entries(tsconfig_paths).reduce((paths, [key, item]) => {
return Object.assign(Object.assign({}, paths), { [key]: node_path_1.default.resolve(item[0]) });
}, {});
}
};
exports.getTsconfigPaths = getTsconfigPaths;
;