Skip to content

Commit

Permalink
fix: readMigrationFiles error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRibbens committed Aug 19, 2024
1 parent 4808e31 commit 98cbdb9
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs'
import { pathToFileURL } from 'node:url'
import path from 'path'

import type { Payload } from '../../index.js'
Expand Down Expand Up @@ -35,9 +36,10 @@ export const readMigrationFiles = async ({

return Promise.all(
files.map(async (filePath) => {
const filename = pathToFileURL(filePath)
// eval used to circumvent errors bundling
let migration = await eval(
`${typeof require === 'function' ? 'require' : 'import'}('${filePath.replaceAll('\\', '/')}')`,
`${typeof require === 'function' ? 'require' : 'import'}('${filename.href}')`,
)
if ('default' in migration) migration = migration.default

Expand Down

0 comments on commit 98cbdb9

Please sign in to comment.