@rxap/ts-morph
Version:
Provides utilities for manipulating TypeScript code using the ts-morph library. It offers a fluent API to add, modify, and remove code elements such as classes, decorators, imports, and properties in both Angular and NestJS projects. This package simplifi
23 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoerceNestModuleProvider = CoerceNestModuleProvider;
const coerce_imports_1 = require("../coerce-imports");
const get_coerce_array_literal_form_object_literal_1 = require("../get-coerce-array-literal-form-object-literal");
const coerce_nest_provider_to_array_1 = require("./coerce-nest-provider-to-array");
const get_nest_module_metadata_1 = require("./get-nest-module-metadata");
function CoerceNestModuleProvider(sourceFile, options) {
const { providerObject, overwrite, moduleSpecifier, } = options;
let { structures } = options;
structures !== null && structures !== void 0 ? structures : (structures = []);
if (moduleSpecifier && typeof providerObject === 'string') {
structures.push({
moduleSpecifier,
namedImports: [providerObject],
});
}
(0, coerce_imports_1.CoerceImports)(sourceFile, structures);
const metadata = (0, get_nest_module_metadata_1.GetNestModuleMetadata)(sourceFile);
const providerArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(metadata, 'providers');
(0, coerce_nest_provider_to_array_1.CoerceNestProviderToArray)(providerObject, providerArray, overwrite);
}
//# sourceMappingURL=coerce-nest-module-provider.js.map