Skip to content

Commit 14264d2

Browse files
committedApr 23, 2021
fix(registry): normalize registry manifests
Other manifest code paths go through read-package-json-fast, which end up normalized through that package's `normalize` function. Manifests picked from the registry do not. This adds consistency between the two.
1 parent 42e977a commit 14264d2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎lib/registry.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const RemoteFetcher = require('./remote.js')
33
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
44
const pacoteVersion = require('../package.json').version
55
const npa = require('npm-package-arg')
6+
const rpj = require('read-package-json-fast')
67
const pickManifest = require('npm-pick-manifest')
78
const ssri = require('ssri')
89
const Minipass = require('minipass')
@@ -156,7 +157,8 @@ class RegistryFetcher extends Fetcher {
156157
}
157158
if (this.integrity)
158159
mani._integrity = String(this.integrity)
159-
return this.package = mani
160+
this.package = rpj.normalize(mani)
161+
return this.package
160162
})
161163
}
162164

‎test/registry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ t.test('underscore, no tag or version', t => {
6161
return f.resolve().then(r => t.equal(r, `${registry}underscore/-/underscore-1.5.1.tgz`))
6262
.then(() => f.manifest()).then(m => {
6363
t.equal(m, f.package)
64-
t.match(m, { version: '1.5.1' })
64+
t.match(m, { version: '1.5.1', _id: 'underscore@1.5.1' })
6565
return f.manifest().then(m2 => t.equal(m, m2, 'manifest cached'))
6666
})
6767
.then(() => f.extract(me + '/underscore'))

0 commit comments

Comments
 (0)
Please sign in to comment.