@angular/cdk
Version:
Angular Material Component Development Kit
46 lines • 2.31 kB
JavaScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTargetTsconfigPath = getTargetTsconfigPath;
exports.getWorkspaceConfigGracefully = getWorkspaceConfigGracefully;
const core_1 = require("@angular-devkit/core");
const workspace_1 = require("@schematics/angular/utility/workspace");
/** Name of the default Angular CLI workspace configuration files. */
const defaultWorkspaceConfigPaths = ['/angular.json', '/.angular.json'];
/** Gets the tsconfig path from the given target within the specified project. */
function getTargetTsconfigPath(project, targetName) {
var _a, _b, _c;
const tsconfig = (_c = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.get(targetName)) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c['tsConfig'];
return tsconfig ? (0, core_1.normalize)(tsconfig) : null;
}
/** Resolve the workspace configuration of the specified tree gracefully. */
function getWorkspaceConfigGracefully(tree) {
return __awaiter(this, void 0, void 0, function* () {
const path = defaultWorkspaceConfigPaths.find(filePath => tree.exists(filePath));
if (!path) {
return null;
}
try {
return (0, workspace_1.getWorkspace)(tree, path);
}
catch (_a) {
return null;
}
});
}
//# sourceMappingURL=project-tsconfig-paths.js.map
;