From 5d602e0de2ac15eff311500d79e3b6336044a256 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Sat, 25 Jul 2020 12:37:51 -0700 Subject: [PATCH] install script support for registry paths (#286) --- CHANGELOG.md | 6 ++++++ npm/esbuild/install.js | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0263328039..eee2f0a4775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +* Custom registry can now have a path ([#286](https://github.com/evanw/esbuild/issues/286)) + + This adds support for custom registries hosted at a path other than `/`. Previously the registry had to be hosted at the domain level, like npm itself. + ## 0.6.6 * Fix minification bug with `this` values for function calls ([#282](https://github.com/evanw/esbuild/issues/282)) diff --git a/npm/esbuild/install.js b/npm/esbuild/install.js index a4756239ef0..6d21d03103e 100644 --- a/npm/esbuild/install.js +++ b/npm/esbuild/install.js @@ -24,14 +24,17 @@ function installBinaryFromPackage(package, fromPath, toPath) { } // Download the package from npm - let pathname = `/${package}/-/${package}-${version}.tgz`; let registry = url.parse('https://registry.npmjs.org/'); try { let env = url.parse(process.env.npm_config_registry || ''); - if (env.protocol !== null && env.host !== null) registry = env; + if (env.protocol !== null && env.host !== null && env.pathname !== null) registry = env; } catch (e) { } - let packageURL = url.format({ protocol: registry.protocol, host: registry.host, pathname }); + let packageURL = url.format({ + protocol: registry.protocol, + host: registry.host, + pathname: path.posix.join(registry.pathname, `${package}/-/${package}-${version}.tgz`), + }); downloadURL(packageURL, (err, buffer) => { if (err) die(`Failed to download ${JSON.stringify(packageURL)}`, err);