-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for scoped registry urls #4
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ const colors = require('colors/safe'); | |
const readline = require('readline'); | ||
|
||
const packageDetailsCache = {}; | ||
const registryUrl = `https://registry.npmjs.org/`; | ||
const npmConfig = require('rc')('npm', { | ||
registry: `https://registry.npmjs.org/` | ||
}); | ||
|
||
/** | ||
* @param {Response} r | ||
|
@@ -70,6 +72,11 @@ module.exports = function getPackageDetails( | |
return Promise.resolve(null); | ||
} | ||
const key = `${name}@${versionLoose}`; | ||
const scope = (/(@[^\/]+)\/.*/.test(name) && /(@[^\/]+)\/.*/.exec(name)[1]) || ``; | ||
var registryUrl = (scope && npmConfig[`${scope}:registry`]) || npmConfig[`registry`]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed together with the remaining eslint errors |
||
if(registryUrl.charAt(registryUrl.length - 1) !== `/`) { | ||
registryUrl += `/`; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
const infoUrl = `${registryUrl}${name.replace(`/`, `%2f`)}`; | ||
if (!packageDetailsCache[key]) { | ||
readline.cursorTo(process.stdout, 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use https://github.com/npm/npm-package-arg (because
npm
uses it)or alternatively copy logic from it to be on safe side 😉
It's difficult to say if your regexp works exactly. the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just changed the parsing to the same logic, thanks for the hint