rake-db 2.3.19 → 2.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +13 -3
package/package.json
CHANGED
package/src/common.ts
CHANGED
|
@@ -11,7 +11,6 @@ import Enquirer from 'enquirer';
|
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import { readdir } from 'fs/promises';
|
|
13
13
|
import { RakeDbAst } from './ast';
|
|
14
|
-
import CallSite = NodeJS.CallSite;
|
|
15
14
|
|
|
16
15
|
type Db = DbResult<DefaultColumnTypes>;
|
|
17
16
|
|
|
@@ -60,16 +59,27 @@ export const processRakeDbConfig = (
|
|
|
60
59
|
const result = { ...migrationConfigDefaults, ...config };
|
|
61
60
|
|
|
62
61
|
if (!result.basePath) {
|
|
63
|
-
let stack: CallSite[] | undefined;
|
|
62
|
+
let stack: NodeJS.CallSite[] | undefined;
|
|
64
63
|
Error.prepareStackTrace = (_, s) => (stack = s);
|
|
65
64
|
new Error().stack;
|
|
66
65
|
if (stack) {
|
|
67
66
|
const thisFile = stack[0]?.getFileName();
|
|
68
67
|
for (const item of stack) {
|
|
69
|
-
|
|
68
|
+
let file = item.getFileName();
|
|
70
69
|
if (!file || file === thisFile || /\bnode_modules\b/.test(file)) {
|
|
71
70
|
continue;
|
|
72
71
|
}
|
|
72
|
+
|
|
73
|
+
// on Windows with ESM file is file:///C:/path/to/file.ts
|
|
74
|
+
// it is not a valid URL
|
|
75
|
+
if (/file:\/\/\/\w+:\//.test(file)) {
|
|
76
|
+
file = decodeURI(file.slice(8));
|
|
77
|
+
} else {
|
|
78
|
+
try {
|
|
79
|
+
file = new URL(file).pathname;
|
|
80
|
+
} catch (_) {}
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
result.basePath = path.dirname(file);
|
|
74
84
|
break;
|
|
75
85
|
}
|