Skip to content

Commit ccd8be4

Browse files
fix
1 parent 6880074 commit ccd8be4

File tree

6 files changed

+20
-28
lines changed

6 files changed

+20
-28
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
}
1818
},
1919
"scripts": {
20-
"test": "node --test --experimental-strip-types test/**.test.ts",
21-
"test:coverage": "node --test --experimental-strip-types --experimental-test-coverage test/**.test.ts",
22-
"cli": "node --experimental-strip-types src/bin.ts",
20+
"test": "node --no-warnings --test --experimental-strip-types test/**.test.ts",
21+
"test:coverage": "node --no-warnings --test --experimental-strip-types --experimental-test-coverage test/**.test.ts",
22+
"cli": "node --no-warnings --experimental-strip-types src/bin.ts",
2323
"build": "rimraf dist dist-esm && tsc && tsc -p tsconfig.esm.json",
2424
"prepack": "node --run build"
2525
},

src/bin.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ 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-
}
3625

3726
function prettyPrintRow(rows: [string, string][]) {
3827
let max = 0;
@@ -149,7 +138,7 @@ if (args.length === 0) {
149138
process.exit(0);
150139
} else if (args.some((arg) => arg === "-v" || arg === "--version")) {
151140
const version = JSON.parse(
152-
fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"),
141+
fs.readFileSync(path.resolve(process.cwd(), "..", "package.json"), "utf-8"),
153142
).version as string;
154143
console.log(version);
155144
process.exit(0);
@@ -159,7 +148,7 @@ if (args.length === 0) {
159148
// `deno publish` cli is under active development and args may change
160149
// frequently.
161150
if (cmd === "publish") {
162-
const binFolder = path.join(__dirname, "..", ".download");
151+
const binFolder = path.resolve(process.cwd(), ".download");
163152
run(async () => {
164153
const projectInfo = await findProjectDir(process.cwd());
165154
return publish(process.cwd(), {

src/download.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import * as fs from "node:fs";
44
import * as path from "node:path";
55
import * as util from "node:util";
66
import * as stream from "node:stream";
7-
import * as StreamZip from "node-stream-zip";
7+
import StreamZipPkg from "node-stream-zip";
88
import { styleText } from "./utils.ts";
99

10+
const { async } = StreamZipPkg;
11+
1012
const streamFinished = util.promisify(stream.finished);
1113

1214
const DENO_CANARY_INFO_URL = "https://dl.deno.land/canary-latest.txt";
@@ -95,7 +97,7 @@ export async function downloadDeno(
9597
const file = path.join(binFolder, info.filename);
9698
await fs.promises.rename(tmpFile, file);
9799

98-
const zip = new StreamZip.async({ file });
100+
const zip = new async({ file });
99101
await zip.extract(null, binFolder);
100102
await zip.close();
101103

test/test_utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export async function runJsr(
3636
...process.env,
3737
npm_config_user_agent: undefined,
3838
...env,
39-
NO_COLOR: "true",
4039
},
4140
captureOutput,
4241
);

tsconfig.esm.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"compilerOptions": {
44
"module": "NodeNext",
55
"target": "ESNext",
6-
"strict": true,
7-
"outDir": "dist-esm/",
8-
"declaration": true
6+
"moduleResolution": "NodeNext",
7+
"outDir": "dist-esm/"
98
},
10-
"include": ["src"]
9+
"include": ["src"],
10+
// we don't want to compile the bin file in ESM mode
11+
"exclude": ["src/bin.ts"]
1112
}

tsconfig.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"compilerOptions": {
3-
"allowImportingTsExtensions": true,
4-
"declaration": true,
5-
"erasableSyntaxOnly": true,
3+
"target": "esnext",
64
"module": "commonjs",
7-
"outDir": "dist",
85
"rewriteRelativeImportExtensions": true,
9-
"rootDir": "src",
6+
"erasableSyntaxOnly": true,
7+
"esModuleInterop": true,
8+
"outDir": "dist",
9+
"strict": true,
10+
"declaration": true,
1011
"sourceMap": true
1112
},
1213
"include": ["src"]

0 commit comments

Comments
 (0)