Skip to content

Commit

Permalink
fix: AwaitEventEmitter is not a constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
unlight committed Dec 17, 2023
1 parent 36b6da7 commit 6f97126
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"' |
Expand Down
11 changes: 8 additions & 3 deletions src/generate.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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<void>;
},
Expand All @@ -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);
Expand Down

0 comments on commit 6f97126

Please sign in to comment.