Skip to content

Skip sha verification when a package is not on npmjs.org #1169

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

Merged
merged 1 commit into from
Nov 10, 2015
Merged
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
12 changes: 10 additions & 2 deletions lib/npm-installation-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,21 @@ export class NpmInstallationManager implements INpmInstallationManager {
return ((): boolean => {
let shasumProperty = "dist.shasum";
let cachedPackagePath = this.getCachedPackagePath(packageName, version);
let realShasum = this.$npm.view(`${packageName}@${version}`, shasumProperty).wait()[version][shasumProperty];
let packageInfo = this.$npm.view(`${packageName}@${version}`, shasumProperty).wait();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case the package is not in npm, this code will fail and we'll never get to the next if... or I'm totally missing something.

My test:

$ npm view app12354242
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "view" "app12354242"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/app12354242
npm ERR! 404
npm ERR! 404 'app12354242' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR!     d:\Work\nativescript-cli\npm-debug.log


if (_.isEmpty(packageInfo)) {
// this package has not been published to npmjs.org yet - perhaps manually added via --framework-path
this.$logger.trace(`Checking shasum of package ${packageName}@${version}: skipped because the package was not found in npmjs.org`);
return true;
}

let realShasum = packageInfo[version][shasumProperty];
let packageTgz = cachedPackagePath + ".tgz";
let currentShasum = "";
if(this.$fs.exists(packageTgz).wait()) {
currentShasum = this.$fs.getFileShasum(packageTgz).wait();
}
this.$logger.trace(`Checking shasum of package: ${packageName}@${version}: expected ${realShasum}, actual ${currentShasum}.`);
this.$logger.trace(`Checking shasum of package ${packageName}@${version}: expected ${realShasum}, actual ${currentShasum}.`);
return realShasum === currentShasum;
}).future<boolean>()();
}
Expand Down