gulp-simple-typescript
Version:
This is a simple typescript parser
33 lines (32 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadCompilerOptions = exports.getConfig = void 0;
const path_1 = require("path");
const gulpSimpleTypescript_1 = require("../definitions/gulpSimpleTypescript");
let tsConfig;
function parseConfig(config) {
const parsedConfig = config;
parsedConfig.target = gulpSimpleTypescript_1.Target[config.target];
parsedConfig.module = gulpSimpleTypescript_1.Module[config.module];
parsedConfig.lib = parsedConfig.lib.map(lib => `lib.${lib}.full.d.ts`);
parsedConfig.paths = preparePaths(config.paths);
return parsedConfig;
}
function preparePaths(paths) {
const pathsObj = {};
const keys = Object.keys(paths).map(path => path.replace('/*', ''));
const values = Object.values(paths);
keys.forEach((key, i) => {
pathsObj[key] = values[i].map(value => value.replace('/*', ''));
});
return pathsObj;
}
function getConfig() {
return tsConfig;
}
exports.getConfig = getConfig;
function loadCompilerOptions(path) {
const fullPath = path_1.resolve(process.cwd(), path || 'tsconfig.json');
tsConfig = parseConfig(require(fullPath).compilerOptions);
}
exports.loadCompilerOptions = loadCompilerOptions;