tycono 0.1.0 → 0.1.2
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 +13 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = dirname(__filename);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
// Resolve tsx using createRequire from THIS file's location
|
|
11
|
+
// This traverses up node_modules correctly for both local and npx flat installs
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const tsxApiPath = pathToFileURL(require.resolve('tsx/esm/api')).href;
|
|
14
|
+
const tsx = await import(tsxApiPath);
|
|
15
|
+
tsx.register();
|
|
16
|
+
|
|
17
|
+
// Now we can import .ts files
|
|
18
|
+
const entryPath = pathToFileURL(join(__dirname, 'tycono.ts')).href;
|
|
19
|
+
const { main } = await import(entryPath);
|
|
10
20
|
await main(process.argv.slice(2));
|