Skip to content

Commit

Permalink
Merge pull request #29 from ScopeSV/27-missing-curly-bracket
Browse files Browse the repository at this point in the history
bug: closes bracket if default switch template builder
  • Loading branch information
ScopeSV authored Nov 2, 2023
2 parents c687e04 + 1490e0c commit aa6837f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/handlers/migrationHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ describe('migrationHandler', () => {
"await db.schema\n\t\t.alterTable('todo')\n\t\t.addColumn('complete', 'boolean', (col) => col.notNull())\n\t\t.execute()"
)
})
it('adds an end if cant find the action', () => {
const template = generateTemplate('do_stuff', []).getTemplate()
expect(template).toContain(
"import { Migration } from 'kysely'\n\nexport const up: Migration['up'] = async (db) => {\n}\n\nexport const down: Migration['down'] = async (db) => {\n}\n\n"
)
})
})
})
6 changes: 5 additions & 1 deletion src/handlers/migrationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const parseInput = (input: string) => {
const inputParts = input.split('_')
const type = inputParts[0]
let tableName
if (type == Commands.CreateTable) {
if (type === Commands.CreateTable) {
tableName = inputParts[1]
} else {
tableName = inputParts[inputParts.length - 1]
Expand Down Expand Up @@ -87,6 +87,10 @@ export const generateTemplate = (
}
)
break

default:
b.addEnd()
break
}

b.addDown().addEnd()
Expand Down

0 comments on commit aa6837f

Please sign in to comment.