Skip to content

Commit

Permalink
check for definitionsFile existence
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Sep 15, 2024
1 parent 3742fc3 commit b1c8d49
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/migrator/src/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ export class Migrator {
const doUpdate = changed && (await params.confirm(diff))

if (doUpdate) {
await fs.mkdir(path.dirname(this.definitionsFile), {recursive: true})
await fs.writeFile(this.definitionsFile, diff)
}
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/migrator/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const createMigratorRouter = (procedure: TRPCProcedureLike<MigratorRouter
.query(async ({ctx}) => {
return {
path: ctx.migrator.definitionsFile,
content: await readFile(ctx.migrator.definitionsFile, 'utf8'),
content: await readFile(ctx.migrator.definitionsFile, 'utf8').catch(() => null),
}
}),
updateDb: trpc.procedure
Expand Down

0 comments on commit b1c8d49

Please sign in to comment.