Skip to content

Commit

Permalink
Merge pull request #4 from killerfurbel/master
Browse files Browse the repository at this point in the history
support for scoped registry urls
  • Loading branch information
delfrrr authored Jun 30, 2018
2 parents 6fb11af + daa4c65 commit 0c2afa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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"
}
}

0 comments on commit 0c2afa8

Please sign in to comment.