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

20 lines 953 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetNgModuleOptionsObject = GetNgModuleOptionsObject; const ts_morph_1 = require("ts-morph"); function GetNgModuleOptionsObject(sourceFile) { const classWithNgModule = sourceFile.getClasses().find(cls => cls.getDecorator('NgModule')); if (!classWithNgModule) { throw new Error('Could not find class with NgModule decorator!'); } const ngModuleDecorator = classWithNgModule.getDecorator('NgModule'); let ngModuleOptions = ngModuleDecorator.getArguments()[0]; if (!ngModuleOptions) { ngModuleOptions = ngModuleDecorator.addArgument(ts_morph_1.Writers.object({})); } if (!(ngModuleOptions.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression))) { throw new Error('The NgModule options is not an object literal expression'); } return ngModuleOptions; } //# sourceMappingURL=get-ng-module-options-object.js.map