UNPKG

@nrwl/workspace

Version:

The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.

40 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRootTsConfigFileName = exports.getRelativePathToRootTsConfig = exports.getRootTsConfigPathInTree = exports.readTsConfig = void 0; const devkit_1 = require("@nrwl/devkit"); const fs_1 = require("fs"); const path_1 = require("path"); const typescript_1 = require("./typescript"); let tsModule; function readTsConfig(tsConfigPath) { if (!tsModule) { tsModule = (0, typescript_1.ensureTypescript)(); } const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile); return tsModule.parseJsonConfigFileContent(readResult.config, tsModule.sys, (0, path_1.dirname)(tsConfigPath)); } exports.readTsConfig = readTsConfig; function getRootTsConfigPathInTree(tree) { for (const path of ['tsconfig.base.json', 'tsconfig.json']) { if (tree.exists(path)) { return path; } } return 'tsconfig.base.json'; } exports.getRootTsConfigPathInTree = getRootTsConfigPathInTree; function getRelativePathToRootTsConfig(tree, targetPath) { return (0, devkit_1.offsetFromRoot)(targetPath) + getRootTsConfigPathInTree(tree); } exports.getRelativePathToRootTsConfig = getRelativePathToRootTsConfig; function getRootTsConfigFileName() { for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) { const tsConfigPath = (0, path_1.join)(devkit_1.workspaceRoot, tsConfigName); if ((0, fs_1.existsSync)(tsConfigPath)) { return tsConfigName; } } return null; } exports.getRootTsConfigFileName = getRootTsConfigFileName; //# sourceMappingURL=ts-config.js.map