diff options
author | 2023-10-05 15:59:02 -0700 | |
---|---|---|
committer | 2023-10-05 15:59:02 -0700 | |
commit | 7ef4cd26ac1e8c3527ff95621497dd77273b299b (patch) | |
tree | b3336822447b35e613ad672ae486e4a439e0870a | |
parent | df1b0c4332ed1ef8de57b5bdcaa4dbe8b1450847 (diff) | |
download | bun-7ef4cd26ac1e8c3527ff95621497dd77273b299b.tar.gz bun-7ef4cd26ac1e8c3527ff95621497dd77273b299b.tar.zst bun-7ef4cd26ac1e8c3527ff95621497dd77273b299b.zip |
Use singular nouns when appropriate on install messages (#2543)
* Use singular nouns when appropriate on install messages
* Fix one more pluralization
* Fix bun-add tests for "1 package installed"
* Fix bun install/remove/update tests for "1 package installed"
-rw-r--r-- | src/install/install.zig | 20 | ||||
-rw-r--r-- | test/cli/install/bun-add.test.ts | 38 | ||||
-rw-r--r-- | test/cli/install/bun-install.test.ts | 126 | ||||
-rw-r--r-- | test/cli/install/bun-link.test.ts | 8 | ||||
-rw-r--r-- | test/cli/install/bun-remove.test.ts | 2 | ||||
-rw-r--r-- | test/cli/install/bun-update.test.ts | 6 |
6 files changed, 102 insertions, 98 deletions
diff --git a/src/install/install.zig b/src/install/install.zig index 83e060e07..abac43493 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -5989,11 +5989,11 @@ pub const PackageManager = struct { clap.parseParam("-D, --development") catch unreachable, clap.parseParam("--optional Add dependency to \"optionalDependencies\"") catch unreachable, clap.parseParam("-E, --exact Add the exact version instead of the ^range") catch unreachable, - clap.parseParam("<POS> ... \"name\" or \"name@version\" of packages to install") catch unreachable, + clap.parseParam("<POS> ... \"name\" or \"name@version\" of package(s) to install") catch unreachable, }; const remove_params = install_params_ ++ [_]ParamType{ - clap.parseParam("<POS> ... \"name\" of packages to remove from package.json") catch unreachable, + clap.parseParam("<POS> ... \"name\" of package(s) to remove from package.json") catch unreachable, }; const link_params = install_params_ ++ [_]ParamType{ @@ -8086,13 +8086,14 @@ pub const PackageManager = struct { if (install_summary.success > 0) { // it's confusing when it shows 3 packages and says it installed 1 - Output.pretty("\n <green>{d}<r> packages<r> installed ", .{@max( + const pkgs_installed = @max( install_summary.success, @as( u32, @truncate(manager.package_json_updates.len), ), - )}); + ); + Output.pretty("\n <green>{d}<r> package{s}<r> installed ", .{ pkgs_installed, if (pkgs_installed == 1) "" else "s" }); Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp()); printed_timestamp = true; Output.pretty("<r>\n", .{}); @@ -8107,7 +8108,7 @@ pub const PackageManager = struct { } } - Output.pretty("\n <r><b>{d}<r> packages removed ", .{manager.summary.remove}); + Output.pretty("\n <r><b>{d}<r> package{s} removed ", .{ manager.summary.remove, if (manager.summary.remove == 1) "" else "s" }); Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp()); printed_timestamp = true; Output.pretty("<r>\n", .{}); @@ -8116,16 +8117,19 @@ pub const PackageManager = struct { const count = @as(PackageID, @truncate(manager.lockfile.packages.len)); if (count != install_summary.skipped) { - Output.pretty("Checked <green>{d} installs<r> across {d} packages <d>(no changes)<r> ", .{ + Output.pretty("Checked <green>{d} install{s}<r> across {d} package{s} <d>(no changes)<r> ", .{ install_summary.skipped, + if (install_summary.skipped == 1) "" else "s", count, + if (count == 1) "" else "s", }); Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp()); printed_timestamp = true; Output.pretty("<r>\n", .{}); } else { - Output.pretty("<r> <green>Done<r>! Checked {d} packages<r> <d>(no changes)<r> ", .{ + Output.pretty("<r> <green>Done<r>! Checked {d} package{s}<r> <d>(no changes)<r> ", .{ install_summary.skipped, + if (install_summary.skipped == 1) "" else "s", }); Output.printStartEndStdout(ctx.start_time, std.time.nanoTimestamp()); printed_timestamp = true; @@ -8134,7 +8138,7 @@ pub const PackageManager = struct { } if (install_summary.fail > 0) { - Output.prettyln("<r>Failed to install <red><b>{d}<r> packages\n", .{install_summary.fail}); + Output.prettyln("<r>Failed to install <red><b>{d}<r> package{s}\n", .{ install_summary.fail, if (install_summary.fail == 1) "" else "s" }); Output.flush(); } } diff --git a/test/cli/install/bun-add.test.ts b/test/cli/install/bun-add.test.ts index 3e3e919c3..62f5cc6cc 100644 --- a/test/cli/install/bun-add.test.ts +++ b/test/cli/install/bun-add.test.ts @@ -69,7 +69,7 @@ it("should add existing package", async () => { ` installed foo@${add_path}`, "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(await file(join(package_dir, "package.json")).text()).toEqual( @@ -278,7 +278,7 @@ it("should add dependency with capital letters", async () => { " installed BaR@0.0.2", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/BaR`, `${root_url}/BaR-0.0.2.tgz`]); @@ -333,7 +333,7 @@ it("should add exact version", async () => { " installed BaR@0.0.2", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/BaR`, `${root_url}/BaR-0.0.2.tgz`]); @@ -388,7 +388,7 @@ it("should add exact version with -E", async () => { " installed BaR@0.0.2", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/BaR`, `${root_url}/BaR-0.0.2.tgz`]); @@ -452,7 +452,7 @@ it("should add dependency with specified semver", async () => { " - baz-run", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -513,7 +513,7 @@ it("should add dependency (GitHub)", async () => { " - uglifyjs", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -673,7 +673,7 @@ it("should add aliased dependency (npm)", async () => { " - baz-run", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -734,7 +734,7 @@ it("should add aliased dependency (GitHub)", async () => { " - uglifyjs", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -818,7 +818,7 @@ it("should let you add the same package twice", async () => { " installed baz@0.0.3", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -933,7 +933,7 @@ it("should install version tagged with `latest` by default", async () => { " installed baz@0.0.3", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -983,7 +983,7 @@ it("should install version tagged with `latest` by default", async () => { expect(out2.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -1047,7 +1047,7 @@ it("should handle Git URL in dependencies (SCP-style)", async () => { " - uglifyjs", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -1107,7 +1107,7 @@ it("should handle Git URL in dependencies (SCP-style)", async () => { const out2 = await new Response(stdout2).text(); expect(out2.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ "", - "Checked 1 installs across 2 packages (no changes)", + "Checked 1 install across 2 packages (no changes)", ]); expect(await exited2).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -1266,7 +1266,7 @@ it("should add dependency without duplication", async () => { " installed bar@0.0.2", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1367,7 +1367,7 @@ it("should add dependency without duplication (GitHub)", async () => { " - uglifyjs", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".bin", ".cache", "uglify-js"]); @@ -1505,7 +1505,7 @@ it("should add dependencies to workspaces directly", async () => { ` installed foo@${relative(package_dir, add_dir)}`, "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(await readdirSorted(join(package_dir))).toEqual([ @@ -1568,7 +1568,7 @@ async function installRedirectsToAdd(saveFlagFirst: boolean) { ` installed foo@${add_path}`, "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(await file(join(package_dir, "package.json")).text()).toInclude("bun-add.test"); @@ -1605,7 +1605,7 @@ it("should add dependency alongside peerDependencies", async () => { " installed bar@0.0.2", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1660,7 +1660,7 @@ it("should add local tarball dependency", async () => { " - baz-run", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 8f922a0e0..6b0d313f9 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -192,7 +192,7 @@ it("should handle empty string in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -380,7 +380,7 @@ it("should handle `workspace:` specifier", async () => { expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@workspace:path/to/bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(requested).toBe(0); @@ -409,7 +409,7 @@ it("should handle `workspace:` specifier", async () => { expect(out2.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@workspace:path/to/bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(requested).toBe(0); @@ -453,7 +453,7 @@ it("should handle workspaces with packages array", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -675,7 +675,7 @@ it("should ignore peerDependencies within workspaces", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Baz@workspace:packages/baz", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -727,7 +727,7 @@ it("should handle life-cycle scripts within workspaces", async () => { " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -784,7 +784,7 @@ it("should handle life-cycle scripts during re-installation", async () => { " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(requested).toBe(0); @@ -816,7 +816,7 @@ it("should handle life-cycle scripts during re-installation", async () => { " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(requested).toBe(0); @@ -848,7 +848,7 @@ it("should handle life-cycle scripts during re-installation", async () => { " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited3).toBe(0); expect(requested).toBe(0); @@ -903,7 +903,7 @@ it("should use updated life-cycle scripts in root during re-installation", async " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(requested).toBe(0); @@ -948,7 +948,7 @@ it("should use updated life-cycle scripts in root during re-installation", async "[scripts:run] Moo", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(requested).toBe(0); @@ -982,7 +982,7 @@ it("should use updated life-cycle scripts in root during re-installation", async "[scripts:run] Moo", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited3).toBe(0); expect(requested).toBe(0); @@ -1037,7 +1037,7 @@ it("should use updated life-cycle scripts in dependency during re-installation", " + Bar@workspace:bar", "[scripts:run] Foo", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(requested).toBe(0); @@ -1081,7 +1081,7 @@ it("should use updated life-cycle scripts in dependency during re-installation", "[scripts:run] Foo", "[scripts:run] Bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(requested).toBe(0); @@ -1115,7 +1115,7 @@ it("should use updated life-cycle scripts in dependency during re-installation", "[scripts:run] Foo", "[scripts:run] Bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited3).toBe(0); expect(requested).toBe(0); @@ -1158,7 +1158,7 @@ it("should ignore workspaces within workspaces", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -1196,7 +1196,7 @@ it("should handle ^0 in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1276,7 +1276,7 @@ it("should handle ^0.0 in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1394,7 +1394,7 @@ it("should handle ^0.0.2 in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1438,7 +1438,7 @@ it("should handle ^0.0.2-rc in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2-rc", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1482,7 +1482,7 @@ it("should handle ^0.0.2-alpha.3+b4d in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2-alpha.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1570,7 +1570,7 @@ it("should handle ^0.0.2rc1 in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2-rc1", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1614,7 +1614,7 @@ it("should handle ^0.0.2_pre3 in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2-_pre3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1658,7 +1658,7 @@ it("should handle ^0.0.2b_4+cafe_b0ba in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2-b_4+cafe_b0ba", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1702,7 +1702,7 @@ it("should handle caret range in dependencies when the registry has prereleased expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@6.3.0", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -1759,7 +1759,7 @@ it("should prefer latest-tagged dependency", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -1815,7 +1815,7 @@ it("should handle dependency aliasing", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -1871,7 +1871,7 @@ it("should handle dependency aliasing (versioned)", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -1927,7 +1927,7 @@ it("should handle dependency aliasing (dist-tagged)", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -1987,7 +1987,7 @@ it("should not reinstall aliased dependencies", async () => { expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + Bar@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -2025,7 +2025,7 @@ it("should not reinstall aliased dependencies", async () => { const out2 = await new Response(stdout2).text(); expect(out2.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ "", - "Checked 1 installs across 2 packages (no changes)", + "Checked 1 install across 2 packages (no changes)", ]); expect(await exited2).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -2238,7 +2238,7 @@ it("should handle unscoped alias on scoped dependency", async () => { " + @barn/moo@0.1.0", " + moo@0.1.0", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/@barn%2fmoo`, `${root_url}/@barn/moo-0.1.0.tgz`]); @@ -2298,7 +2298,7 @@ it("should handle scoped alias on unscoped dependency", async () => { " + @baz/bar@0.0.2", " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -2493,7 +2493,7 @@ it("should handle GitHub URL in dependencies (user/repo)", async () => { let out = await new Response(stdout).text(); out = out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, ""); out = out.replace(/(github:[^#]+)#[a-f0-9]+/, "$1"); - expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 packages installed"]); + expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 package installed"]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); expect(requested).toBe(0); @@ -2547,7 +2547,7 @@ it("should handle GitHub URL in dependencies (user/repo#commit-id)", async () => expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@github:mishoo/UglifyJS#e219a9a", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -2613,7 +2613,7 @@ it("should handle GitHub URL in dependencies (user/repo#tag)", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@github:mishoo/UglifyJS#e219a9a", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -2842,7 +2842,7 @@ it("should handle GitHub URL in dependencies (github:user/repo#tag)", async () = expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@github:mishoo/UglifyJS#e219a9a", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -2910,7 +2910,7 @@ it("should handle GitHub URL in dependencies (https://github.com/user/repo.git)" let out = await new Response(stdout).text(); out = out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, ""); out = out.replace(/(github:[^#]+)#[a-f0-9]+/, "$1"); - expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 packages installed"]); + expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 package installed"]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); expect(requested).toBe(0); @@ -2964,7 +2964,7 @@ it("should handle GitHub URL in dependencies (git://github.com/user/repo.git#com expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@github:mishoo/UglifyJS#e219a9a", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3032,7 +3032,7 @@ it("should handle GitHub URL in dependencies (git+https://github.com/user/repo.g let out = await new Response(stdout).text(); out = out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, ""); out = out.replace(/(github:[^#]+)#[a-f0-9]+/, "$1"); - expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 packages installed"]); + expect(out.split(/\r?\n/)).toEqual([" + uglify@github:mishoo/UglifyJS", "", " 1 package installed"]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); expect(requested).toBe(0); @@ -3088,7 +3088,7 @@ it("should handle GitHub tarball URL in dependencies (https://github.com/user/re expect(out.split(/\r?\n/)).toEqual([ " + when@https://github.com/cujojs/when/tarball/1.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3147,7 +3147,7 @@ it("should handle GitHub tarball URL in dependencies (https://github.com/user/re expect(out.split(/\r?\n/)).toEqual([ " + when@https://github.com/cujojs/when/tarball/1.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3430,7 +3430,7 @@ it("should not regard peerDependencies declarations as duplicates", async () => expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -3672,7 +3672,7 @@ it("should handle Git URL in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify-js@git+https://git@github.com/mishoo/UglifyJS.git", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3733,7 +3733,7 @@ it("should handle Git URL in dependencies (SCP-style)", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@git+ssh://github.com:mishoo/UglifyJS.git", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3792,7 +3792,7 @@ it("should handle Git URL with committish in dependencies", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + uglify@git+https://git@github.com/mishoo/UglifyJS.git#e219a9a78a0d2251e4dcbd4bb9034207eb484fe8", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -3935,7 +3935,7 @@ it("should de-duplicate committish in Git URLs", async () => { " + uglify-hash@git+https://git@github.com/mishoo/UglifyJS.git#e219a9a78a0d2251e4dcbd4bb9034207eb484fe8", " + uglify-ver@git+https://git@github.com/mishoo/UglifyJS.git#e219a9a78a0d2251e4dcbd4bb9034207eb484fe8", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -4223,7 +4223,7 @@ it("should prefer optionalDependencies over dependencies of the same name", asyn expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -4276,7 +4276,7 @@ it("should prefer dependencies over peerDependencies of the same name", async () expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.5", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.5.tgz`]); @@ -4321,7 +4321,7 @@ it("should handle tarball URL", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ ` + baz@${root_url}/baz-0.0.3.tgz`, "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz-0.0.3.tgz`]); @@ -4369,7 +4369,7 @@ it("should handle tarball path", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ ` + baz@${join(import.meta.dir, "baz-0.0.3.tgz")}`, "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -4416,7 +4416,7 @@ it("should handle tarball URL with aliasing", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ ` + bar@${root_url}/baz-0.0.3.tgz`, "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz-0.0.3.tgz`]); @@ -4464,7 +4464,7 @@ it("should handle tarball path with aliasing", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ ` + bar@${join(import.meta.dir, "baz-0.0.3.tgz")}`, "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -5091,7 +5091,7 @@ it("should ignore invalid workspaces from parent directory", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -5147,7 +5147,7 @@ it("should handle --cwd", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@0.0.2", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); @@ -5510,7 +5510,7 @@ it("should handle `workspaces:*` and `workspace:*` gracefully", async () => { expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(requested).toBe(0); @@ -5540,7 +5540,7 @@ it("should handle `workspaces:*` and `workspace:*` gracefully", async () => { expect(out2.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(requested).toBe(0); @@ -5583,7 +5583,7 @@ it("should handle `workspaces:bar` and `workspace:*` gracefully", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -5626,7 +5626,7 @@ it("should handle `workspaces:*` and `workspace:bar` gracefully", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -5669,7 +5669,7 @@ it("should handle `workspaces:bar` and `workspace:bar` gracefully", async () => expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); @@ -6265,7 +6265,7 @@ it("should override npm dependency by matching workspace", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:bar", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -6355,7 +6355,7 @@ it("should override @scoped npm dependency by matching workspace", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + @bar/baz@workspace:packages/bar-baz", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); @@ -6404,7 +6404,7 @@ it("should override aliased npm dependency by matching workspace", async () => { expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + bar@workspace:baz", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited).toBe(0); expect(urls.sort()).toBeEmpty(); diff --git a/test/cli/install/bun-link.test.ts b/test/cli/install/bun-link.test.ts index 39872b072..5d2fffc39 100644 --- a/test/cli/install/bun-link.test.ts +++ b/test/cli/install/bun-link.test.ts @@ -85,7 +85,7 @@ it("should link package", async () => { ` installed ${link_name}@link:${link_name}`, "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); @@ -186,7 +186,7 @@ it("should link scoped package", async () => { ` installed ${link_name}@link:${link_name}`, "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); @@ -292,7 +292,7 @@ it("should link dependency without crashing", async () => { expect(out2.replace(/\s*\[[0-9\.]+ms\]\s*$/, "").split(/\r?\n/)).toEqual([ ` + ${link_name}@link:${link_name}`, "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".bin", ".cache", link_name].sort()); @@ -341,6 +341,6 @@ it("should link dependency without crashing", async () => { expect(err4).toContain(`error: FileNotFound installing ${link_name}`); expect(stdout4).toBeDefined(); const out4 = await new Response(stdout4).text(); - expect(out4.replace(/\[[0-9\.]+m?s\]/, "[]").split(/\r?\n/)).toEqual(["Failed to install 1 packages", "[] done", ""]); + expect(out4.replace(/\[[0-9\.]+m?s\]/, "[]").split(/\r?\n/)).toEqual(["Failed to install 1 package", "[] done", ""]); expect(await exited4).toBe(0); }); diff --git a/test/cli/install/bun-remove.test.ts b/test/cli/install/bun-remove.test.ts index 5b029f143..2b70900dd 100644 --- a/test/cli/install/bun-remove.test.ts +++ b/test/cli/install/bun-remove.test.ts @@ -102,7 +102,7 @@ it("should remove existing package", async () => { expect(out1.replace(/\s*\[[0-9\.]+m?s\]/, "").split(/\r?\n/)).toEqual([ ` + pkg2@${pkg2_path}`, "", - " 1 packages installed", + " 1 package installed", " Removed: 1", "", ]); diff --git a/test/cli/install/bun-update.test.ts b/test/cli/install/bun-update.test.ts index c7d4fdd85..7cdfb3a97 100644 --- a/test/cli/install/bun-update.test.ts +++ b/test/cli/install/bun-update.test.ts @@ -67,7 +67,7 @@ it("should update to latest version of dependency", async () => { expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited1).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.3.tgz`]); @@ -113,7 +113,7 @@ it("should update to latest version of dependency", async () => { " - baz-exec", "", "", - " 1 packages installed", + " 1 package installed", ]); expect(await exited2).toBe(0); expect(urls.sort()).toEqual([`${root_url}/baz`, `${root_url}/baz-0.0.5.tgz`]); @@ -296,7 +296,7 @@ it("lockfile should not be modified when there are no version changes, issue#588 expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ " + baz@0.0.3", "", - " 1 packages installed", + " 1 package installed", ]); // Test if the lockb has been modified by `bun update`. |