From b4fc751b3bfe65a97d6a1c9b4379c5bad5b49c61 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Sun, 22 Sep 2024 09:45:19 -0300 Subject: [PATCH] fix: generation --- src/emitter.ts | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/emitter.ts b/src/emitter.ts index eac7634..8ea127a 100644 --- a/src/emitter.ts +++ b/src/emitter.ts @@ -9,28 +9,29 @@ export function before() { return (sf: ts.SourceFile) => { const visitNode = (node: ts.Node): ts.Node => { try { - if ((tsBinary.isMethodDeclaration(node) - || tsBinary.isPropertyDeclaration(node) - || tsBinary.isClassDeclaration(node)) - && !tsBinary.getDecorators(node)?.length + if ( + (tsBinary.isMethodDeclaration(node) || + tsBinary.isPropertyDeclaration(node) || + tsBinary.isClassDeclaration(node)) && + !tsBinary.getDecorators(node)?.length ) { const decorator = tsBinary.factory.createDecorator( - tsBinary.factory.createPropertyAccessChain( - tsBinary.factory.createCallExpression( - tsBinary.factory.createIdentifier('require'), - undefined, - [ - tsBinary.factory.createStringLiteral('nestjs-emitter'), - ] - ), undefined, 'simpleDecorator' - ) + tsBinary.factory.createCallExpression( + tsBinary.factory.createIdentifier('require'), + undefined, + [ + tsBinary.factory.createStringLiteral( + 'nestjs-emitter/dist/emitter', + ), + ], + ), ); node = tsBinary.isClassDeclaration(node) ? tsBinary.visitEachChild(node, visitNode, ctx) - : tsBinary.factory.replaceDecoratorsAndModifiers( - node, - [...(node.modifiers ?? []), decorator] - ); + : tsBinary.factory.replaceDecoratorsAndModifiers(node, [ + ...(node.modifiers ?? []), + decorator, + ]); return node; } return tsBinary.visitEachChild(node, visitNode, ctx);