Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 27, 2020 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/9ac4c3849153bff998b7b862520e44c2 to your computer and use it in GitHub Desktop.
Save isaacs/9ac4c3849153bff998b7b862520e44c2 to your computer and use it in GitHub Desktop.
diff --git a/index.js b/index.js
index 2324e7f..c52adf8 100644
--- a/index.js
+++ b/index.js
@@ -21,15 +21,25 @@ const urlIsValid = u => {
}
}
+const parsePublishConfig = (publishConfig = {}) => {
+ const opt = {}
+ for (const [key, value] of publishConfig) {
+ if (key === 'registry' || /^(@|\/\/)/.test(key)) {
+ opts[key] = value
+ }
+ }
+ return opt
+}
+
module.exports = regFetch
function regFetch (uri, /* istanbul ignore next */ opts_ = {}) {
const opts = {
...defaultOpts,
- ...opts_
+ ...opts_,
+ ...parsePublishConfig(opts_.publishConfig)
}
const registry = opts.registry = (
(opts.spec && pickRegistry(opts.spec, opts)) ||
- (opts.publishConfig && opts.publishConfig.registry) ||
opts.registry ||
/* istanbul ignore next */
'https://registry.npmjs.org/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment