Skip to content

Commit 6880074

Browse files
fix __dirname
1 parent 0889ed8 commit 6880074

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ import {
2222
import type { PkgManagerName } from "./pkg_manager.ts";
2323

2424
const args = process.argv.slice(2);
25+
let __dirname: string;
26+
27+
// @ts-ignore
28+
if (import.meta.url) {
29+
// @ts-ignore
30+
__dirname = path.dirname(new URL(import.meta.url).pathname);
31+
} else {
32+
// For Node.js environments that do not support import.meta.url
33+
// which means commonjs environments.
34+
__dirname = globalThis.__dirname;
35+
}
2536

2637
function prettyPrintRow(rows: [string, string][]) {
2738
let max = 0;

0 commit comments

Comments
 (0)