|
8 | 8 |
|
9 | 9 | import { createReadStream, createWriteStream } from 'node:fs'; |
10 | 10 | import { mkdir, readdir } from 'node:fs/promises'; |
11 | | -import { createRequire } from 'node:module'; |
12 | | -import { basename, dirname, extname, join, resolve } from 'node:path'; |
| 11 | +import { basename, extname, resolve } from 'node:path'; |
13 | 12 | import type { QueryResult } from 'pg'; |
14 | 13 | import type { DBConnection } from './db'; |
15 | 14 | import MigrationBuilder from './migrationBuilder'; |
@@ -135,23 +134,12 @@ export class Migration implements RunMigration { |
135 | 134 | ? now.toISOString().replace(/\D/g, '') |
136 | 135 | : now.valueOf(); |
137 | 136 |
|
138 | | - const crossRequire = createRequire( |
139 | | - // @ts-expect-error: ignore until esm only |
140 | | - import.meta.url || __dirname |
141 | | - ); |
142 | | - const moduleDir = dirname( |
143 | | - crossRequire.resolve('node-pg-migrate/package.json') |
144 | | - ); |
145 | | - |
146 | 137 | const templateFileName = |
147 | 138 | 'templateFileName' in options |
148 | 139 | ? resolve(process.cwd(), options.templateFileName) |
149 | 140 | : resolve( |
150 | | - moduleDir, |
151 | | - join( |
152 | | - 'templates', |
153 | | - `migration-template.${await resolveSuffix(directory, options)}` |
154 | | - ) |
| 141 | + 'node_modules/node-pg-migrate/templates', |
| 142 | + `migration-template.${await resolveSuffix(directory, options)}` |
155 | 143 | ); |
156 | 144 | const suffix = getSuffixFromFileName(templateFileName); |
157 | 145 |
|
|
0 commit comments