fix: migrate error on windows (#7759)
handle windows compatible file names when reading migrations --------- Co-authored-by: Alessio Gravili <alessio@gravili.de>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import path from 'path'
|
||||
|
||||
import type { Payload } from '../../index.js'
|
||||
@@ -36,9 +37,10 @@ export const readMigrationFiles = async ({
|
||||
return Promise.all(
|
||||
files.map(async (filePath) => {
|
||||
// eval used to circumvent errors bundling
|
||||
let migration = await eval(
|
||||
`${typeof require === 'function' ? 'require' : 'import'}('${filePath.replaceAll('\\', '/')}')`,
|
||||
)
|
||||
let migration =
|
||||
typeof require === 'function'
|
||||
? await eval(`require('${filePath.replaceAll('\\', '/')}')`)
|
||||
: await eval(`import('${pathToFileURL(filePath).href}')`)
|
||||
if ('default' in migration) migration = migration.default
|
||||
|
||||
const result: Migration = {
|
||||
|
||||
Reference in New Issue
Block a user