spindb 0.17.2 → 0.17.3
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/bin/cli.js +15 -8
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
|
4
4
|
import { dirname, join } from 'node:path'
|
|
5
5
|
import { spawn } from 'node:child_process'
|
|
6
6
|
import { existsSync } from 'node:fs'
|
|
7
|
+
import { createRequire } from 'node:module'
|
|
7
8
|
|
|
8
9
|
// Get the directory of this file
|
|
9
10
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -20,18 +21,24 @@ const mainScript = join(packageRoot, 'cli', 'bin.ts')
|
|
|
20
21
|
// 3. Arguments pass through without shell interpretation (shell: false)
|
|
21
22
|
// 4. Works on Windows without needing to spawn .cmd files
|
|
22
23
|
|
|
23
|
-
// Find tsx ESM loader
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
join(packageRoot, 'node_modules', 'tsx', 'dist', 'loader.mjs'),
|
|
27
|
-
]
|
|
24
|
+
// Find tsx ESM loader using Node's module resolution
|
|
25
|
+
// This works with npm, pnpm, yarn regardless of hoisting/symlink structure
|
|
26
|
+
let tsxLoader = null
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
try {
|
|
29
|
+
const require = createRequire(import.meta.url)
|
|
30
|
+
const tsxDir = dirname(require.resolve('tsx/package.json'))
|
|
31
|
+
const loaderPaths = [
|
|
32
|
+
join(tsxDir, 'dist', 'esm', 'index.mjs'),
|
|
33
|
+
join(tsxDir, 'dist', 'loader.mjs'),
|
|
34
|
+
]
|
|
35
|
+
tsxLoader = loaderPaths.find((p) => existsSync(p))
|
|
36
|
+
} catch {
|
|
37
|
+
// tsx not found via module resolution
|
|
38
|
+
}
|
|
30
39
|
|
|
31
40
|
if (!tsxLoader) {
|
|
32
41
|
console.error('Error: tsx loader not found.')
|
|
33
|
-
console.error('Searched paths:')
|
|
34
|
-
tsxLoaderPaths.forEach((p) => console.error(` - ${p}`))
|
|
35
42
|
console.error('\nTry running: pnpm install')
|
|
36
43
|
process.exit(1)
|
|
37
44
|
}
|