Skip to content

Commit

Permalink
reverted schema generation exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
gallayl committed Jun 2, 2024
1 parent d2111b1 commit abf758a
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions common/src/bin/create-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,21 @@ export const apiValues: SchemaGenerationSetting[] = [
]

export const exec = async (): Promise<void> => {
await Promise.all(
[...entityValues, ...apiValues].map(async (schemaValue) => {
try {
const inputFile = join(process.cwd(), schemaValue.inputFile)
const outputFile = join(process.cwd(), schemaValue.outputFile)

console.log(`Create schema from ${inputFile} to ${outputFile}`)
const schema = createGenerator({
path: inputFile,
tsconfig: join(process.cwd(), './tsconfig.json'),
skipTypeCheck: true,
expose: 'all',
}).createSchema(schemaValue.type)
await promises.writeFile(outputFile, JSON.stringify(schema, null, 2))
console.log(`Schema generated succesfully.`)
} catch (error) {
console.error(`There was an error generating schema from ${schemaValue.inputFile}`, error)
throw error
}
}),
)
for (const schemaValue of [...entityValues, ...apiValues]) {
try {
console.log(`Create schema from ${schemaValue.inputFile} to ${schemaValue.outputFile}`)
const schema = createGenerator({
path: join(process.cwd(), schemaValue.inputFile),
tsconfig: join(process.cwd(), './tsconfig.json'),
skipTypeCheck: true,
expose: 'all',
}).createSchema(schemaValue.type)
await promises.writeFile(join(process.cwd(), schemaValue.outputFile), JSON.stringify(schema, null, 2))
} catch (error) {
console.error(`There was an error generating schema from ${schemaValue.inputFile}`, error)
process.exit(1)
}
}
}

exec().catch((error) => {
console.error('Schema generation failed', error)
process.exit(1)
})
exec()

0 comments on commit abf758a

Please sign in to comment.