diff options
author | 2022-12-26 07:20:35 +0200 | |
---|---|---|
committer | 2022-12-25 21:20:35 -0800 | |
commit | 74251fbf5e011191721c96ea520f29a7cc4ea94a (patch) | |
tree | 600e52c4dce92afca5bb9befe00ca6f6d0f20fbc /src/install/npm.zig | |
parent | 08a738c6c8841dcb1b84933b483396d66d702f87 (diff) | |
download | bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.tar.gz bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.tar.zst bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.zip |
[install] use default URL when only auth token is specified (#1664)
Previously it would default to `http://localhost/` which was inconsistent with the case sans token.
Use official `npm` registry as fallback in both cases.
Diffstat (limited to 'src/install/npm.zig')
-rw-r--r-- | src/install/npm.zig | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig index 965157d50..3874c2c01 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -35,12 +35,7 @@ const ComptimeStringMap = @import("../comptime_string_map.zig").ComptimeStringMa const Npm = @This(); pub const Registry = struct { - url: URL = URL.parse("https://registry.npmjs.org/"), - scopes: Map = Map{}, - - token: string = "", - auth: string = "", - + pub const DefaultURL = "https://registry.npmjs.org/"; pub const BodyPool = ObjectPool(MutableString, MutableString.init2048, true, 8); pub const Scope = struct { @@ -72,7 +67,7 @@ pub const Registry = struct { pub fn fromAPI(name: string, registry_: Api.NpmRegistry, allocator: std.mem.Allocator, env: *DotEnv.Loader) !Scope { var registry = registry_; - var url = URL.parse(registry.url); + var url = URL.parse(if (registry.url.len == 0) DefaultURL else registry.url); var auth: string = ""; if (registry.token.len == 0) { @@ -620,15 +615,15 @@ pub const PackageManifest = struct { pub fn reportSize(this: *const PackageManifest) void { Output.prettyErrorln( - \\ Versions count: {d} - \\ External Strings count: {d} + \\ Versions count: {d} + \\ External Strings count: {d} \\ Package Versions count: {d} - \\ + \\ \\ Bytes: \\ - \\ Versions: {d} - \\ External: {d} - \\ Packages: {d} + \\ Versions: {d} + \\ External: {d} + \\ Packages: {d} \\ Strings: {d} \\ Total: {d} , .{ |