aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/install/bunx.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/install/bunx.test.ts')
-rw-r--r--test/bun.js/install/bunx.test.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/bun.js/install/bunx.test.ts b/test/bun.js/install/bunx.test.ts
index e43dd673d..06266fe94 100644
--- a/test/bun.js/install/bunx.test.ts
+++ b/test/bun.js/install/bunx.test.ts
@@ -11,7 +11,7 @@ import { readdirSorted } from "./dummy.registry";
let x_dir;
beforeEach(async () => {
- x_dir = realpathSync(await mkdtemp(join(tmpdir(), "bun-install.test")));
+ x_dir = realpathSync(await mkdtemp(join(tmpdir(), "bun-x.test")));
});
afterEach(async () => {
await rm(x_dir, { force: true, recursive: true });
@@ -179,3 +179,31 @@ for (const entry of await decompress(Buffer.from(buffer))) {
expect(await exited).toBe(0);
expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]);
});
+
+it("should execute from current working directory", async () => {
+ await writeFile(
+ join(x_dir, "test.js"),
+ `
+console.log(
+6
+*
+7
+)`,
+ );
+ const { stdout, stderr, exited } = spawn({
+ cmd: [bunExe(), "--bun", "x", "uglify-js", "test.js", "--compress"],
+ cwd: x_dir,
+ stdout: null,
+ stdin: "pipe",
+ stderr: "pipe",
+ env,
+ });
+ expect(stderr).toBeDefined();
+ const err = await new Response(stderr).text();
+ expect(err).not.toContain("error");
+ expect(stdout).toBeDefined();
+ const out = await new Response(stdout).text();
+ expect(out.split(/\r?\n/)).toEqual(["console.log(42);", ""]);
+ expect(await exited).toBe(0);
+ expect(await readdirSorted(x_dir)).toEqual(["test.js"]);
+});