UNPKG

@rxap/schematics-ts-morph

Version:

This package provides utilities for manipulating TypeScript code using ts-morph, particularly for Angular and NestJS projects. It offers functions to add, coerce, and modify code elements like classes, methods, decorators, and imports. The package also in

25 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HasComponent = HasComponent; const schematics_1 = require("@angular-devkit/schematics"); const workspace_utilities_1 = require("@rxap/workspace-utilities"); const has_project_feature_1 = require("./has-project-feature"); const path_1 = require("path"); const build_angular_base_path_1 = require("./build-angular-base-path"); function HasComponent(host, options) { const { project, feature, name, } = options; if (!(0, workspace_utilities_1.HasProject)(host, project)) { throw new schematics_1.SchematicsException(`The component '${name}' does not exists. The project '${project}' does not exists.`); } const type = (0, workspace_utilities_1.GetProjectType)(host, project); if (type !== 'library' && !(0, has_project_feature_1.HasProjectFeature)(host, options)) { throw new schematics_1.SchematicsException(`The component '${name}' does not exists. The project '${project}' has not the feature '${feature}'.`); } let basePath = (0, build_angular_base_path_1.BuildAngularBasePath)(host, options); if (!basePath.endsWith(name)) { basePath = (0, path_1.join)(basePath, name); } const fullPath = (0, path_1.join)(basePath, name + '.component.ts'); return host.exists(fullPath); } //# sourceMappingURL=has-component.js.map