Skip to content
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

Merged
merged 2 commits into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/getPackageDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,6 +72,11 @@ module.exports = function getPackageDetails(
return Promise.resolve(null);
}
const key = `${name}@${versionLoose}`;
const scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined;
let registryUrl = (scope && npmConfig[`${scope}:registry`]) || npmConfig.registry;
if (registryUrl.charAt(registryUrl.length - 1) !== `/`) {
registryUrl += `/`;
}
const infoUrl = `${registryUrl}${name.replace(`/`, `%2f`)}`;
if (!packageDetailsCache[key]) {
readline.cursorTo(process.stdout, 0);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"promise-queue": "^2.2.3",
"semver": "^5.4.1",
"spdx-correct": "^2.0.4",
"spdx-satisfies": "^0.1.3"
"spdx-satisfies": "^0.1.3",
"rc": "^1.2.8"
}
}