From 6f971262fdc62d518b7eeeb99fa2361d28138416 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 17 Dec 2023 21:52:53 +0400 Subject: [PATCH] fix: AwaitEventEmitter is not a constructor close: #200 --- Taskfile | 2 +- src/generate.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Taskfile b/Taskfile index a497dfe1..420cffb7 100644 --- a/Taskfile +++ b/Taskfile @@ -9,7 +9,7 @@ build() { # https://esbuild.github.io/api/#target cp -fv src/bin.js dist cp -fv README.md LICENSE dist - npx pkgroll --target=es2020 + npx pkgroll --target=es2020 --export-condition=node cat package.json | jq '.main = "./index.cjs"' | jq '.types = "./index.d.ts"' | jq '.exports.".".require = "./index.cjs"' | diff --git a/src/generate.ts b/src/generate.ts index 3d3fde74..3bbd6038 100644 --- a/src/generate.ts +++ b/src/generate.ts @@ -1,6 +1,5 @@ import { GeneratorOptions } from '@prisma/generator-helper'; import { ok } from 'assert'; -import AwaitEventEmitter from 'await-event-emitter'; import { mapKeys } from 'lodash'; import { Project, QuoteKind } from 'ts-morph'; @@ -30,12 +29,15 @@ import { ObjectSettings, OutputType, } from './types'; +const AwaitEventEmitter = require('await-event-emitter').default; + +import AEE from 'await-event-emitter'; export async function generate( args: GeneratorOptions & { skipAddOutputSourceFiles?: boolean; connectCallback?: ( - emitter: AwaitEventEmitter, + emitter: AEE, eventArguments: EventArguments, ) => void | Promise; }, @@ -53,7 +55,10 @@ export async function generate( if (config.emitBlocks.prismaEnums || config.emitBlocks.schemaEnums) { eventEmitter.on('EnumType', registerEnum); } - if (config.emitBlocks.outputs || config.emitBlocks.models && !config.omitModelsCount) { + if ( + config.emitBlocks.outputs || + (config.emitBlocks.models && !config.omitModelsCount) + ) { eventEmitter.on('OutputType', outputType); } config.emitBlocks.models && eventEmitter.on('ModelOutputType', modelOutputType);