tscpaths
Version:
Replace absolute paths to relative paths after typescript compilation
33 lines • 912 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
exports.mapPaths = (paths, mapper) => {
const dest = {};
Object.keys(paths).forEach((key) => {
dest[key] = paths[key].map(mapper);
});
return dest;
};
exports.loadConfig = (file) => {
const { extends: ext, compilerOptions: { baseUrl, outDir, paths } = {
baseUrl: undefined,
outDir: undefined,
paths: undefined,
}, } = require(file);
const config = {};
if (baseUrl) {
config.baseUrl = baseUrl;
}
if (outDir) {
config.outDir = outDir;
}
if (paths) {
config.paths = paths;
}
if (ext) {
const parentConfig = exports.loadConfig(path_1.resolve(path_1.dirname(file), ext));
return Object.assign({}, parentConfig, config);
}
return config;
};
//# sourceMappingURL=util.js.map