@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
39 lines (33 loc) • 1.16 kB
JavaScript
;
var os = require('os');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var os__default = /*#__PURE__*/_interopDefault(os);
// Lazy: defer `typescript` (~115 ms) until a CLI command actually loads tsconfig
let lazyTs;
const tsLib = ()=>{
if (!lazyTs) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
lazyTs = require('typescript');
}
return lazyTs;
};
/**
* @description Load a tsconfig.json file and return the parsed config.
*
* @internal
*/ const loadTsConfig = ({ cwd, path, logger })=>{
const tsApi = tsLib();
const configPath = tsApi.findConfigFile(cwd, tsApi.sys.fileExists, path);
if (!configPath) {
return undefined;
}
const configFile = tsApi.readConfigFile(configPath, tsApi.sys.readFile);
const parsedConfig = tsApi.parseJsonConfigFileContent(configFile.config, tsApi.sys, cwd);
logger.debug(`Loaded user TS config:`, os__default.default.EOL, parsedConfig);
return {
config: parsedConfig,
path: configPath
};
};
exports.loadTsConfig = loadTsConfig;
//# sourceMappingURL=tsconfig.js.map