diff options
author | 2023-02-16 15:06:35 -0800 | |
---|---|---|
committer | 2023-02-16 15:06:35 -0800 | |
commit | 5007c6b218ec0e42938eac9c8a9698e313dc9952 (patch) | |
tree | 4a00d7b0ffceb5dd4be0b6971d82dde1e0e8d2f5 /test/bun.js | |
parent | d95404fd7a096c58bf7c3d844e6fac13dd9c7d22 (diff) | |
download | bun-5007c6b218ec0e42938eac9c8a9698e313dc9952.tar.gz bun-5007c6b218ec0e42938eac9c8a9698e313dc9952.tar.zst bun-5007c6b218ec0e42938eac9c8a9698e313dc9952.zip |
Support yarn-like `"workspaces"."packages": string[]` (#2086)
* [workspaces] Support yarn-like `"workspaces"."packages": string[]`
* Add a test
* :scissors:
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/install/bun-install.test.ts | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/test/bun.js/install/bun-install.test.ts b/test/bun.js/install/bun-install.test.ts index 7de46869f..5e21fd394 100644 --- a/test/bun.js/install/bun-install.test.ts +++ b/test/bun.js/install/bun-install.test.ts @@ -16,6 +16,7 @@ import { root_url, setHandler, } from "./dummy.registry"; +import { rmSync } from "fs"; beforeAll(dummyBeforeAll); afterAll(dummyAfterAll); @@ -188,6 +189,50 @@ it("should handle workspaces", async () => { await access(join(package_dir, "bun.lockb")); }); +it("should handle workspaces with packages array", async () => { + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "Foo", + version: "0.0.1", + workspaces: { packages: ["bar"] }, + }), + ); + await mkdir(join(package_dir, "bar")); + await writeFile( + join(package_dir, "bar", "package.json"), + JSON.stringify({ + name: "Bar", + version: "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@workspace:bar", + "", + " 1 packages installed", + ]); + expect(await exited).toBe(0); + expect(requested).toBe(0); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "Bar"]); + expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(join("..", "bar")); + await access(join(package_dir, "bun.lockb")); +}); + it("should handle inter-dependency between workspaces", async () => { await writeFile( join(package_dir, "package.json"), @@ -1948,7 +1993,7 @@ it("should report error on invalid format for workspaces", async () => { name: "foo", version: "0.0.1", workspaces: { - packages: ["bar"], + packages: { bar: true }, }, }), ); @@ -1970,7 +2015,7 @@ it("should report error on invalid format for workspaces", async () => { '"workspaces": [', ' "path/to/package"', "]", - '{"name":"foo","version":"0.0.1","workspaces":{"packages":["bar"]}}', + '{"name":"foo","version":"0.0.1","workspaces":{"packages":{"bar":true}}}', " ^", `${package_dir}/package.json:1:33 32`, "", |