From 56b5bf52c7b63e4311ce09a64da309aacfb6ded5 Mon Sep 17 00:00:00 2001 From: Pengju Xu Date: Sun, 18 Jan 2026 09:06:00 +0000 Subject: [PATCH] test: improve bin_shebang test case add testing for file under some dir path, not just root dir --- tests/bin_shebang_project/dir/main.ts | 2 ++ tests/bin_shebang_project/main.ts | 2 +- tests/integration.test.ts | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 tests/bin_shebang_project/dir/main.ts diff --git a/tests/bin_shebang_project/dir/main.ts b/tests/bin_shebang_project/dir/main.ts new file mode 100644 index 0000000..3f23fa4 --- /dev/null +++ b/tests/bin_shebang_project/dir/main.ts @@ -0,0 +1,2 @@ +#!/usr/bin/env -S NO_COLOR=true deno run +console.log("Hello!"); diff --git a/tests/bin_shebang_project/main.ts b/tests/bin_shebang_project/main.ts index 4b9f391..f630dc5 100644 --- a/tests/bin_shebang_project/main.ts +++ b/tests/bin_shebang_project/main.ts @@ -1,2 +1,2 @@ -#!/usr/local/bin/node +#!/usr/bin/env -S NO_COLOR=true deno run --unstable-raw-imports --no-config --allow-env --allow-net=jsr.io:443 console.log("Hello!"); diff --git a/tests/integration.test.ts b/tests/integration.test.ts index f6a8668..9a73305 100644 --- a/tests/integration.test.ts +++ b/tests/integration.test.ts @@ -396,11 +396,18 @@ Deno.test("should build bin project", async () => { Deno.test("should build bin project with a shebang", async () => { await runTest("bin_shebang_project", { - entryPoints: [{ - kind: "bin", - name: "hello", - path: "./main.ts", - }], + entryPoints: [ + { + kind: "bin", + name: "hello", + path: "./main.ts", + }, + { + kind: "bin", + name: "hellodir", + path: "./dir/main.ts", + }, + ], shims: getAllShimOptions(false), outDir: "./npm", package: { @@ -416,6 +423,7 @@ Deno.test("should build bin project with a shebang", async () => { version: "1.0.0", bin: { hello: "./esm/main.js", + hellodir: "./esm/dir/main.js", }, scripts: { test: "node test_runner.js", @@ -431,6 +439,14 @@ Deno.test("should build bin project with a shebang", async () => { output.getFileText("script/main.js"), expectedText, ); + assertEquals( + output.getFileText("script/dir/main.js"), + expectedText, + ); + assertEquals( + output.getFileText("esm/dir/main.js"), + expectedText, + ); assertEquals( output.getFileText("esm/main.js"), expectedText,