aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bun.js/install/bunx.test.ts30
-rw-r--r--test/bun.js/path.test.js1
2 files changed, 30 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"]);
+});
diff --git a/test/bun.js/path.test.js b/test/bun.js/path.test.js
index 176d98c8e..ad5688ea7 100644
--- a/test/bun.js/path.test.js
+++ b/test/bun.js/path.test.js
@@ -274,6 +274,7 @@ it("path.relative", () => {
["/baz-quux", "/baz", "../baz"],
["/baz", "/baz-quux", "../baz-quux"],
["/page1/page2/foo", "/", "../../.."],
+ [process.cwd(), "foo", "foo"],
],
],
];