diff options
Diffstat (limited to 'src/install/npm.zig')
-rw-r--r-- | src/install/npm.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig index 9f3f2952c..fec545b0c 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -68,6 +68,17 @@ pub const Registry = struct { pub fn fromAPI(name: string, registry_: Api.NpmRegistry, allocator: std.mem.Allocator, env: *DotEnv.Loader) !Scope { var registry = registry_; + + // Support $ENV_VAR for registry URLs + if (strings.startsWithChar(registry_.url, '$')) { + // If it became "$ENV_VAR/", then we need to remove the trailing slash + if (env.get(strings.trim(registry_.url[1..], "/"))) |replaced_url| { + if (replaced_url.len > 1) { + registry.url = replaced_url; + } + } + } + var url = URL.parse(registry.url); var auth: string = ""; |