diff --git a/src/cli/publish_command.zig b/src/cli/publish_command.zig index 5bf2696867..077ba0544d 100644 --- a/src/cli/publish_command.zig +++ b/src/cli/publish_command.zig @@ -334,7 +334,7 @@ pub const PublishCommand = struct { Global.crash(); }; - publish(false, &context, cli.tolerate_republish) catch |err| { + publish(false, &context) catch |err| { switch (err) { error.OutOfMemory => bun.outOfMemory(), error.NeedAuth => { @@ -381,7 +381,7 @@ pub const PublishCommand = struct { // TODO: read this into memory _ = bun.sys.unlink(context.abs_tarball_path); - publish(true, &context, cli.tolerate_republish) catch |err| { + publish(true, &context) catch |err| { switch (err) { error.OutOfMemory => bun.outOfMemory(), error.NeedAuth => { @@ -471,7 +471,6 @@ pub const PublishCommand = struct { pub fn publish( comptime directory_publish: bool, ctx: *const Context(directory_publish), - tolerate_republish: bool, ) PublishError!void { const registry = ctx.manager.scopeForPackageName(ctx.package_name); @@ -483,6 +482,7 @@ pub const PublishCommand = struct { // When --tolerate-republish is enabled, we should check if package version already exists // BEFORE doing any expensive work (packing, uploading, etc.) by making a GET request // to the registry API. For now, we use the reactive approach below. + const tolerate_republish = ctx.manager.options.publish_config.tolerate_republish; // continues from `printSummary` Output.pretty( diff --git a/src/install/PackageManager/PackageManagerOptions.zig b/src/install/PackageManager/PackageManagerOptions.zig index c1c9c4b596..c0e7622fa0 100644 --- a/src/install/PackageManager/PackageManagerOptions.zig +++ b/src/install/PackageManager/PackageManagerOptions.zig @@ -79,6 +79,7 @@ pub const PublishConfig = struct { tag: string = "", otp: string = "", auth_type: ?AuthType = null, + tolerate_republish: bool = false, }; pub const Access = enum { @@ -636,6 +637,7 @@ pub fn load( if (cli.publish_config.auth_type) |auth_type| { this.publish_config.auth_type = auth_type; } + this.publish_config.tolerate_republish = cli.tolerate_republish; if (cli.ca.len > 0) { this.ca = cli.ca;