diff options
Diffstat (limited to 'test/cli/run/run-extensionless.test.ts')
-rw-r--r-- | test/cli/run/run-extensionless.test.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/cli/run/run-extensionless.test.ts b/test/cli/run/run-extensionless.test.ts new file mode 100644 index 000000000..642c274d9 --- /dev/null +++ b/test/cli/run/run-extensionless.test.ts @@ -0,0 +1,31 @@ +import { expect, test } from "bun:test"; +import { mkdirSync, realpathSync } from "fs"; +import { bunEnv, bunExe } from "harness"; +import { writeFileSync } from "fs"; +import { tmpdir } from "os"; +import { join } from "path"; + +test("running extensionless file works", async () => { + const dir = join(realpathSync(tmpdir()), "bun-run-test1"); + mkdirSync(dir, { recursive: true }); + await Bun.write(join(dir, "cool"), "const x: Test = 2; console.log('hello world');"); + let { stdout } = Bun.spawnSync({ + cmd: [bunExe(), join(dir, "./cool")], + cwd: dir, + env: bunEnv, + }); + expect(stdout.toString("utf8")).toEqual("hello world\n"); +}); + +test("running shebang typescript file works", async () => { + const dir = join(realpathSync(tmpdir()), "bun-run-test2"); + mkdirSync(dir, { recursive: true }); + writeFileSync(join(dir, "cool"), `#!${bunExe()}\nconst x: Test = 2; console.log('hello world');`, { mode: 0o777 }); + + let { stdout } = Bun.spawnSync({ + cmd: [join(dir, "./cool")], + cwd: dir, + env: bunEnv, + }); + expect(stdout.toString("utf8")).toEqual("hello world\n"); +}); |