diff options
author | 2023-02-10 19:23:40 +0200 | |
---|---|---|
committer | 2023-02-10 09:23:40 -0800 | |
commit | 09585c4b24c8cf6ffa3b0c10d98b144bea8b298e (patch) | |
tree | 277b1e0abd3263d0ddb3018988d71fc2d8ecf153 /test/bun.js | |
parent | 5181aa54e243eca70b363b6163ba669b5cbb5b06 (diff) | |
download | bun-09585c4b24c8cf6ffa3b0c10d98b144bea8b298e.tar.gz bun-09585c4b24c8cf6ffa3b0c10d98b144bea8b298e.tar.zst bun-09585c4b24c8cf6ffa3b0c10d98b144bea8b298e.zip |
[install] fix duplicate check on `peerDependencies` (#2039)
fixes #2037
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/install/bun-install.test.ts | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/test/bun.js/install/bun-install.test.ts b/test/bun.js/install/bun-install.test.ts index 063cd3720..8cd826615 100644 --- a/test/bun.js/install/bun-install.test.ts +++ b/test/bun.js/install/bun-install.test.ts @@ -1685,7 +1685,6 @@ it("should consider peerDependencies during hoisting", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", " + moo@workspace:moo", - " + baz@0.0.5", "", " 4 packages installed", ]); @@ -1721,3 +1720,49 @@ it("should consider peerDependencies during hoisting", async () => { expect(await readdirSorted(join(package_dir, "moo"))).toEqual(["package.json"]); await access(join(package_dir, "bun.lockb")); }); + +it("should not regard peerDependencies declarations as duplicates", async () => { + const urls: string[] = []; + setHandler(dummyRegistry(urls)); + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "foo", + version: "0.0.1", + dependencies: { + bar: "*", + }, + peerDependencies: { + bar: "^0.0.2", + }, + }), + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "install", "--config", import.meta.dir + "/basic.toml"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("Saved lockfile"); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + " + bar@0.0.2", + "", + " 1 packages installed", + ]); + expect(await exited).toBe(0); + expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); + expect(requested).toBe(2); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "bar"]); + expect(await readdirSorted(join(package_dir, "node_modules", "bar"))).toEqual(["package.json"]); + expect(await file(join(package_dir, "node_modules", "bar", "package.json")).json()).toEqual({ + name: "bar", + version: "0.0.2", + }); + await access(join(package_dir, "bun.lockb")); +}); |