From 91dec4522df94bc69c6e8a1d12f99f72fb7404e0 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Thu, 26 Oct 2023 14:23:16 -0400 Subject: [PATCH] Pre-approve esm.sh network calls for easy access to transpiled modules during local-run. --- src/local-run.ts | 3 ++- src/tests/local-run.test.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/local-run.ts b/src/local-run.ts index 88b2cab..ab192b4 100644 --- a/src/local-run.ts +++ b/src/local-run.ts @@ -75,8 +75,9 @@ export const getCommandline = function ( } else { allowedDomains.push("slack.com"); } - // Add deno.land to allow uncached remote deps + // Add deno.land and esm.sh to allow uncached remote deps allowedDomains.push("deno.land"); + allowedDomains.push("esm.sh"); command.push("--allow-net=" + allowedDomains.join(",")); command.push(findRelativeFile(mainModule, "local-run-function.ts")); diff --git a/src/tests/local-run.test.ts b/src/tests/local-run.test.ts index 1b84964..f8d164b 100644 --- a/src/tests/local-run.test.ts +++ b/src/tests/local-run.test.ts @@ -43,7 +43,7 @@ Deno.test("getCommandline function", async (t) => { "--config=deno.jsonc", "--allow-read", "--allow-env", - "--allow-net=example.com,slack.com,deno.land", + "--allow-net=example.com,slack.com,deno.land,esm.sh", FAKE_DENO_LAND_EXPECTED_MODULE, ]); }); @@ -64,7 +64,7 @@ Deno.test("getCommandline function", async (t) => { "--allow-read", "--allow-env", "--unsafely-ignore-certificate-errors=dev1234.slack.com", - "--allow-net=example.com,dev1234.slack.com,deno.land", + "--allow-net=example.com,dev1234.slack.com,deno.land,esm.sh", FAKE_DENO_LAND_EXPECTED_MODULE, ]); }); @@ -84,7 +84,7 @@ Deno.test("getCommandline function", async (t) => { "--config=deno.jsonc", "--allow-read", "--allow-env", - "--allow-net=slack.com,deno.land", + "--allow-net=slack.com,deno.land,esm.sh", FAKE_DENO_LAND_EXPECTED_MODULE, ]); }); @@ -104,7 +104,7 @@ Deno.test("getCommandline function", async (t) => { "--config=deno.jsonc", "--allow-read", "--allow-env", - "--allow-net=slack.com,deno.land", + "--allow-net=slack.com,deno.land,esm.sh", FAKE_FILE_EXPECTED_MODULE, ]); }); @@ -124,7 +124,7 @@ Deno.test("getCommandline function", async (t) => { "--config=deno.jsonc", "--allow-read", "--allow-env", - "--allow-net=example.com,slack.com,deno.land", + "--allow-net=example.com,slack.com,deno.land,esm.sh", "file:///local-run-function.ts", ]); }); @@ -146,7 +146,7 @@ Deno.test("getCommandline function", async (t) => { "--config=deno.jsonc", "--allow-read", "--allow-env", - "--allow-net=example.com,slack.com,deno.land", + "--allow-net=example.com,slack.com,deno.land,esm.sh", "file:///local-run-function.ts", "--mycustomflag", ]);