Skip to content

Commit

Permalink
#7 fix hash for github requests
Browse files Browse the repository at this point in the history
  • Loading branch information
delfrrr committed Aug 10, 2018
1 parent 324aacc commit f73060c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/getPackageDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getSizeAndLicenseFromGitHub(owner, repo) {
* @returns {object} dependencies, name, version
*/
function getPackageJsonFromGitHub(owner, repo, ref) {
const packageJsonUrl = `${gitHubApiUrl}repos/${owner}/${repo}/contents/package.json?ref=${ref}`;// I believe size of downloaded repo will not depend on ref
const packageJsonUrl = `${gitHubApiUrl}repos/${owner}/${repo}/contents/package.json?ref=${ref}`;
readline.cursorTo(process.stdout, 0);
readline.clearLine(process.stdout, 1);
process.stdout.write(`GET ${packageJsonUrl}`);
Expand Down Expand Up @@ -120,8 +120,10 @@ function getPackageDetailsFromGitHub({ host, path, hash, protocol }, versionLoos
if (!owner || !repo) {
throw new Error(`Cannot parse github dependency url ${versionLoose}`)
}
const ref = hash || 'master';
// const key = ['github', owner, repo, ref];
let ref = 'master';
if (hash && hash.slice(1)) {
ref = hash.slice(1);
}
return Promise.all([
getSizeAndLicenseFromGitHub(owner, repo),
getPackageJsonFromGitHub(owner, repo, ref)
Expand Down

0 comments on commit f73060c

Please sign in to comment.