UNPKG

@nestjs/schematics

Version:

Nest - modern, fast, powerful node.js web framework (@schematics)

31 lines (30 loc) 1.1 kB
import { capitalize, classify } from '@angular-devkit/core/src/utils/strings'; import { ModuleImportDeclarator } from './module-import.declarator.js'; import { ModuleMetadataDeclarator } from './module-metadata.declarator.js'; export class ModuleDeclarator { imports; metadata; constructor(imports = new ModuleImportDeclarator(), metadata = new ModuleMetadataDeclarator()) { this.imports = imports; this.metadata = metadata; } declare(content, options) { options = this.computeSymbol(options); content = this.imports.declare(content, options); content = this.metadata.declare(content, options); return content; } computeSymbol(options) { const target = Object.assign({}, options); if (options.className) { target.symbol = options.className; } else if (options.type !== undefined) { target.symbol = classify(options.name).concat(capitalize(options.type)); } else { target.symbol = classify(options.name); } return target; } }