Skip to content

Commit

Permalink
install script support for registry paths (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 25, 2020
1 parent 2b48759 commit 5d602e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
9 changes: 6 additions & 3 deletions npm/esbuild/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5d602e0

Please sign in to comment.