diff --git a/src/fetchers/tarball-fetcher.js b/src/fetchers/tarball-fetcher.js index f770c4c361..b98fb307eb 100644 --- a/src/fetchers/tarball-fetcher.js +++ b/src/fetchers/tarball-fetcher.js @@ -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'); diff --git a/src/resolvers/registries/npm-resolver.js b/src/resolvers/registries/npm-resolver.js index d00078de36..8c35c44589 100644 --- a/src/resolvers/registries/npm-resolver.js +++ b/src/resolvers/registries/npm-resolver.js @@ -181,6 +181,10 @@ export default class NpmResolver extends RegistryResolver { async resolve(): Promise { // 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; @@ -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); @@ -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) diff --git a/src/types.js b/src/types.js index c4a191d95e..189e606ab1 100644 --- a/src/types.js +++ b/src/types.js @@ -40,7 +40,7 @@ export type PackageRemote = { reference: string, resolved?: ?string, hash: ?string, - integrity?: Object, + integrity?: ?string, packageName?: string, };