Skip to content

Commit 690caeb

Browse files
committed
fix packaging test path and run permission checks
1 parent 5c64175 commit 690caeb

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

packaging.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import { assertEquals } from "jsr:@std/assert@^1.0.0";
2+
import { fromFileUrl } from "jsr:@std/path@^1.0.0/from-file-url";
23
import { join } from "node:path";
34
import { pathToFileURL } from "node:url";
45

56
const workspaceRoot = new URL(".", import.meta.url);
6-
const workspacePath = workspaceRoot.pathname;
7-
const packagingRunPermission = await Deno.permissions.query({
8-
name: "run",
9-
});
7+
const workspacePath = fromFileUrl(workspaceRoot);
8+
const packagingRunPermissions = await Promise.all([
9+
Deno.permissions.query({ name: "run", command: "deno" }),
10+
Deno.permissions.query({ name: "run", command: "node" }),
11+
Deno.permissions.query({
12+
name: "run",
13+
command: Deno.build.os === "windows" ? "where" : "which",
14+
}),
15+
]);
16+
const packagingRunPermissionGranted = packagingRunPermissions.every(
17+
(permission) => permission.state === "granted",
18+
);
1019

1120
const decodeText = (value: Uint8Array): string =>
1221
new TextDecoder().decode(value);
@@ -45,7 +54,7 @@ const run = async (
4554

4655
Deno.test({
4756
name: "built npm package loads in node through the published ESM entrypoint",
48-
ignore: packagingRunPermission.state !== "granted",
57+
ignore: !packagingRunPermissionGranted,
4958
fn: async () => {
5059
const build = await run("deno", ["task", "build"]);
5160
assertEquals(build.code, 0, build.stderr || build.stdout);

0 commit comments

Comments
 (0)