diff options
author | 2023-03-05 18:54:00 +0200 | |
---|---|---|
committer | 2023-03-05 08:54:00 -0800 | |
commit | c7bfb3aa3acdd1c8b11782530110aaf417cb79b8 (patch) | |
tree | b5a14c85dc652142757790a2141ea9e9b574dc11 /test | |
parent | 72737131581bd30fbae66b7de00dc88cee08e207 (diff) | |
download | bun-c7bfb3aa3acdd1c8b11782530110aaf417cb79b8.tar.gz bun-c7bfb3aa3acdd1c8b11782530110aaf417cb79b8.tar.zst bun-c7bfb3aa3acdd1c8b11782530110aaf417cb79b8.zip |
consider current working directory when resolving relative paths (#2313)
* consider current working directory when resolving relative paths
fixes #2298
* comment test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/bun.js/install/bunx.test.ts | 30 | ||||
-rw-r--r-- | test/bun.js/path.test.js | 1 |
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"], ], ], ]; |