Skip to content

Commit

Permalink
fix: remove duplicate registered message
Browse files Browse the repository at this point in the history
  • Loading branch information
YassinEldeeb committed Jan 8, 2022
1 parent e683517 commit 3c4e4ed
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { getDMMF } from '@prisma/sdk'
import fs from 'fs'
import { getDMMF, getSchemaSync } from '@prisma/sdk'
import path from 'path'

const samplePrismaSchema = fs.readFileSync(
path.join(__dirname, './sample.prisma'),
'utf-8',
)
const samplePrismaSchema = getSchemaSync(path.join(__dirname, './sample.prisma'))

export const getSampleDMMF = async () => {
return getDMMF({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { DMMF } from '@prisma/generator-helper'
import { genEnum } from '../helpers/genEnum'
import { getSampleDMMF } from './__fixtures__/getSampleDMMF'

let sampleDMMF: DMMF.Document
beforeAll(async () => {
sampleDMMF = await getSampleDMMF()
})
test('enum generation', async () => {
const sampleDMMF = await getSampleDMMF()

test('enum generation', () => {
sampleDMMF.datamodel.enums.forEach((enumInfo) => {
expect(genEnum(enumInfo)).toMatchSnapshot(enumInfo.name)
})
Expand Down
3 changes: 2 additions & 1 deletion packages/cpg-template-typescript/template/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { genEnum } from './helpers/genEnum'
import { writeFileSafely } from './utils/writeFileSafely'

const { version } = require('../package.json')

generatorHandler({
onManifest() {
logger.info(`${GENERATOR_NAME}:Registered`)
Expand All @@ -16,7 +17,7 @@ generatorHandler({
}
},
onGenerate: async (options: GeneratorOptions) => {
options.dmmf.datamodel.enums.forEach(async (enumInfo) => {
options.dmmf.datamodel.enums.forEach(async (enumInfo) => {
const tsEnum = genEnum(enumInfo)

const writeLocation = path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const formatFile = (content: string): Promise<string> => {

res(formatted)
} catch (error) {
console.error(error)
rej(error)
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { getDMMF } from '@prisma/sdk'
import fs from 'fs'
import { getDMMF, getSchemaSync } from '@prisma/sdk'
import path from 'path'

const samplePrismaSchema = fs.readFileSync(
path.join(__dirname, './sample.prisma'),
'utf-8',
)
const samplePrismaSchema = getSchemaSync(path.join(__dirname, './sample.prisma'))

export const getSampleDMMF = async () => {
return getDMMF({
Expand Down
2 changes: 1 addition & 1 deletion packages/cpg-template/template/src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GENERATOR_NAME } from './constants'
import { genEnum } from './helpers/genEnum'
import { writeFileSafely } from './utils/writeFileSafely'

logger.info(`${GENERATOR_NAME}:Registered`)
const { version } = require('../package.json')

generatorHandler({
onManifest() {
Expand Down
1 change: 0 additions & 1 deletion packages/cpg-template/template/src/utils/formatFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const formatFile = (content) => {

res(formatted)
} catch (error) {
console.error(error)
rej(error)
}
}),
Expand Down

0 comments on commit 3c4e4ed

Please sign in to comment.