Created
October 27, 2020 15:56
-
-
Save isaacs/9ac4c3849153bff998b7b862520e44c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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