|
1 | 1 | import { assertEquals } from "jsr:@std/assert@^1.0.0"; |
| 2 | +import { fromFileUrl } from "jsr:@std/path@^1.0.0/from-file-url"; |
2 | 3 | import { join } from "node:path"; |
3 | 4 | import { pathToFileURL } from "node:url"; |
4 | 5 |
|
5 | 6 | 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 | +); |
10 | 19 |
|
11 | 20 | const decodeText = (value: Uint8Array): string => |
12 | 21 | new TextDecoder().decode(value); |
@@ -45,7 +54,7 @@ const run = async ( |
45 | 54 |
|
46 | 55 | Deno.test({ |
47 | 56 | name: "built npm package loads in node through the published ESM entrypoint", |
48 | | - ignore: packagingRunPermission.state !== "granted", |
| 57 | + ignore: !packagingRunPermissionGranted, |
49 | 58 | fn: async () => { |
50 | 59 | const build = await run("deno", ["task", "build"]); |
51 | 60 | assertEquals(build.code, 0, build.stderr || build.stdout); |
|
0 commit comments