From fc45ef9a14a0546bd43ed9fc9ba340f9554e36f9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 7 Apr 2024 02:09:27 -0700 Subject: [PATCH 1/4] If any failed to install, always exit with non-zero --- src/install/install.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/install/install.zig b/src/install/install.zig index 85459399592303..d091b2fbbc62a7 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -2194,6 +2194,8 @@ pub const PackageManager = struct { // actually have scripts to run, and we add them to this list trusted_deps_to_add_to_package_json: std.ArrayListUnmanaged(string) = .{}, + any_failed_to_install: bool = false, + const PreallocatedNetworkTasks = std.BoundedArray(NetworkTask, 1024); const NetworkTaskQueue = std.HashMapUnmanaged(u64, void, IdentityContext(u64), 80); pub var verbose_install = false; @@ -8011,6 +8013,10 @@ pub const PackageManager = struct { switch (manager.options.log_level) { inline else => |log_level| try manager.updatePackageJSONAndInstallWithManager(ctx, op, log_level), } + + if (manager.any_failed_to_install) { + Global.exit(1); + } } fn updatePackageJSONAndInstallWithManager( @@ -8383,6 +8389,10 @@ pub const PackageManager = struct { try switch (manager.options.log_level) { inline else => |log_level| manager.installWithManager(ctx, package_json_contents, log_level), }; + + if (manager.any_failed_to_install) { + Global.exit(1); + } } pub const PackageInstaller = struct { @@ -10466,6 +10476,10 @@ pub const PackageManager = struct { } } + if (install_summary.fail > 0) { + manager.any_failed_to_install = true; + } + Output.flush(); } From 57a0e2210ae6144eb24fe6efadcb5cc648f4f0c8 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 7 Apr 2024 09:12:06 +0000 Subject: [PATCH 2/4] [autofix.ci] apply automated fixes --- packages/bun-types/bun.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index 3a7165b9d50572..e2e48007883474 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -3000,7 +3000,7 @@ declare module "bun" { * * Due to this limitation, while the internal counter may continue beyond this point, * the precision of the returned value will degrade after 14.8 weeks of uptime (when the nanosecond - * count exceeds Number.MAX_SAFE_INTEGER). Beyond this point, the function will continue to count but + * count exceeds Number.MAX_SAFE_INTEGER). Beyond this point, the function will continue to count but * with reduced precision, which might affect time calculations and comparisons in long-running applications. * * @returns {number} The number of nanoseconds since the process was started, with precise values up to From 8e101a8dc38dd2446199d05901c219deec3d521f Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 7 Apr 2024 16:07:51 -0700 Subject: [PATCH 3/4] This test should fail --- test/cli/install/bun-link.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/install/bun-link.test.ts b/test/cli/install/bun-link.test.ts index 5d97ec6051708a..7bf29cf23b3f30 100644 --- a/test/cli/install/bun-link.test.ts +++ b/test/cli/install/bun-link.test.ts @@ -512,5 +512,5 @@ it("should link dependency without crashing", async () => { "[] done", "", ]); - expect(await exited4).toBe(0); + expect(await exited4).toBe(1); }); From 1387037dc528430c36e3b147e07a365b659a21e5 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 7 Apr 2024 16:08:21 -0700 Subject: [PATCH 4/4] Update bun-link.test.ts --- test/cli/install/bun-link.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cli/install/bun-link.test.ts b/test/cli/install/bun-link.test.ts index 7bf29cf23b3f30..7079050da262da 100644 --- a/test/cli/install/bun-link.test.ts +++ b/test/cli/install/bun-link.test.ts @@ -512,5 +512,7 @@ it("should link dependency without crashing", async () => { "[] done", "", ]); + + // This should fail with a non-zero exit code. expect(await exited4).toBe(1); });