Skip to content

Commit

Permalink
chore(integrity): fixed new flow issues
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif committed Feb 26, 2018
1 parent a0ec613 commit ab3edf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default class TarballFetcher extends BaseFetcher {

_findIntegrity(): ?Object {
if (this.remote.integrity) {
return this.remote.integrity;
return ssri.parse(this.remote.integrity);
}
if (this.hash) {
return ssri.fromHex(this.hash, 'sha1');
Expand Down
10 changes: 5 additions & 5 deletions src/resolvers/registries/npm-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export default class NpmResolver extends RegistryResolver {
async resolve(): Promise<Manifest> {
// lockfile
const shrunk = this.request.getLocked('tarball');
if (shrunk && shrunk._remote && shrunk._remote.integrity) {
// if the integrity field does not exist, it needs to be created
return shrunk;
}
if (shrunk) {
if (this.config.packBuiltPackages && shrunk.prebuiltVariants && shrunk._remote) {
const prebuiltVariants = shrunk.prebuiltVariants;
Expand All @@ -195,10 +199,6 @@ export default class NpmResolver extends RegistryResolver {
}
}
}
if (shrunk && shrunk._remote && shrunk._remote.integrity) {
// if the integrity field does not exist, it needs to be created
return shrunk;
}

const desiredVersion = shrunk && shrunk.version ? shrunk.version : null;
const info: ?Manifest = await this.resolveRequest(desiredVersion);
Expand All @@ -207,7 +207,7 @@ export default class NpmResolver extends RegistryResolver {
}

const {deprecated, dist} = info;
if (shrunk) {
if (shrunk && shrunk._remote) {
shrunk._remote.integrity =
dist && dist.integrity
? ssri.parse(dist.integrity)
Expand Down
2 changes: 1 addition & 1 deletion src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type PackageRemote = {
reference: string,
resolved?: ?string,
hash: ?string,
integrity?: Object,
integrity?: ?string,
packageName?: string,
};

Expand Down

0 comments on commit ab3edf7

Please sign in to comment.