UNPKG

dts-bundle-generator

Version:
25 lines (24 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = require("path"); var ts = require("typescript"); var logger_1 = require("./logger"); function getCompilerOptionsForFile(filePath) { // special case for windows var searchPath = path.join(ts.sys.getCurrentDirectory(), filePath).replace(/\\/g, '/'); var configFileName = ts.findConfigFile(searchPath, ts.sys.fileExists); if (!configFileName) { throw new Error("Cannot find config file"); } logger_1.verboseLog("Using config: " + configFileName); var configParseResult = ts.readConfigFile(configFileName, ts.sys.readFile); if (configParseResult.error) { throw new Error("Error while process tsconfig file: " + JSON.stringify(configParseResult.error)); } var compilerOptionsParseResult = ts.convertCompilerOptionsFromJson(configParseResult.config.compilerOptions, './'); if (compilerOptionsParseResult.errors.length !== 0) { throw new Error("Error while process tsconfig compiler options: " + JSON.stringify(compilerOptionsParseResult.errors)); } return compilerOptionsParseResult.options; } exports.getCompilerOptionsForFile = getCompilerOptionsForFile;