Skip to content

Commit

Permalink
fix: file URL when importing migrations so ESM will work on windows
Browse files Browse the repository at this point in the history
closes #201
closes #203
  • Loading branch information
MikesGlitch authored and wesleytodd committed Nov 21, 2023
1 parent 1ed0f4c commit 22e0ee8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/load-migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const path = require('path')
const fs = require('fs').promises
const url = require('node:url')
const Migration = require('./migration')

module.exports = loadMigrationsIntoSet
Expand Down Expand Up @@ -45,7 +46,7 @@ function loadMigrationsIntoSet (options, fn) {
mod = require(filepath)
} catch (e) {
if (e.code === 'ERR_REQUIRE_ESM') {
mod = await import(filepath)
mod = await import(url.pathToFileURL(filepath))
} else {
return fn(e)
}
Expand Down

0 comments on commit 22e0ee8

Please sign in to comment.