diff options
author | Coty <13724650+cotyhamilton@users.noreply.github.com> | 2024-09-02 19:01:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-02 23:01:36 +0000 |
commit | 2533d68cabb5a38be891a9807c452ca802401d46 (patch) | |
tree | 71d2d1334cc78b9b04797856f59ccf5ede8ad35d /cli/tools/init/mod.rs | |
parent | f6eab6c4bd7a8bba35f13fd353ac319625373553 (diff) |
fix(cli/tools): correct `deno init --serve` template behavior (#25318)
Diffstat (limited to 'cli/tools/init/mod.rs')
-rw-r--r-- | cli/tools/init/mod.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/cli/tools/init/mod.rs b/cli/tools/init/mod.rs index b9ae803c7..2d6a894e1 100644 --- a/cli/tools/init/mod.rs +++ b/cli/tools/init/mod.rs @@ -37,7 +37,7 @@ const routes: Route[] = [ }, { pattern: new URLPattern({ pathname: "/static/*" }), - handler: (req) => serveDir(req, { urlRoot: "./" }), + handler: (req) => serveDir(req), }, ]; @@ -52,7 +52,6 @@ export default { return handler(req); }, } satisfies Deno.ServeDefaultExport; - "#, )?; create_file( @@ -80,13 +79,23 @@ Deno.test(async function serverFetchUsers() { }); Deno.test(async function serverFetchStatic() { - const req = new Request("https://deno.land/static/main.ts"); + const req = new Request("https://deno.land/static/hello.js"); const res = await server.fetch(req); - assertEquals(res.headers.get("content-type"), "text/plain;charset=UTF-8"); + assertEquals(await res.text(), 'console.log("Hello, world!");\n'); + assertEquals(res.headers.get("content-type"), "text/javascript; charset=UTF-8"); }); "#, )?; + let static_dir = dir.join("static"); + std::fs::create_dir_all(&static_dir)?; + create_file( + &static_dir, + "hello.js", + r#"console.log("Hello, world!"); +"#, + )?; + create_json_file( &dir, "deno.json", @@ -203,7 +212,7 @@ Deno.test(function addTest() { info!(" deno task dev"); info!(""); info!(" {}", colors::gray("# Run the tests")); - info!(" deno -R test"); + info!(" deno test -R"); } else if init_flags.lib { info!(" {}", colors::gray("# Run the tests")); info!(" deno test"); |