mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
Co-authored-by: nektro <nektro@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { mkdirSync } from "fs";
|
|
import { bunEnv, bunExe, isWindows, tmpdirSync } from "harness";
|
|
import { writeFileSync } from "fs";
|
|
import { join } from "path";
|
|
|
|
test("running extensionless file works", async () => {
|
|
const dir = tmpdirSync();
|
|
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.skipIf(isWindows)("running shebang typescript file works", async () => {
|
|
const dir = tmpdirSync();
|
|
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");
|
|
});
|