Skip to content

Commit

Permalink
fix(pack): detect unresolved package properly
Browse files Browse the repository at this point in the history
Fixes npm#3132
  • Loading branch information
zepatrik committed Apr 23, 2021
1 parent 88f13e8 commit ab6e220
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pack.js
Expand Up @@ -53,7 +53,7 @@ class Pack extends BaseCommand {
for (const arg of args) {
const spec = npa(arg)
const manifest = await pacote.manifest(spec, this.npm.flatOptions)
if (!manifest._id)
if (!manifest.name || !manifest.version)
throw new Error('Invalid package, must have name and version')

const filename = `${manifest.name}-${manifest.version}.tgz`
Expand Down
28 changes: 28 additions & 0 deletions test/lib/pack.js
Expand Up @@ -190,6 +190,34 @@ t.test('invalid packument', (t) => {
})
})

t.test('real pacote remote integration test', (t) => {
const Pack = t.mock('../../lib/pack.js', {
libnpmpack,
npmlog: {
notice: () => {},
showProgress: () => {},
clearProgress: () => {},
},
})
const npm = mockNpm({
config: {
unicode: true,
json: true,
'dry-run': true,
},
output,
})
const pack = new Pack(npm)

return pack.exec(['ory-prettier-styles@1.1.2'], err => {
t.error(err, { bail: true })

const filename = 'ory-prettier-styles-1.1.2.tgz'
t.strictSame(OUTPUT, [[filename]])
t.end()
})
})

t.test('workspaces', (t) => {
const testDir = t.testdir({
'package.json': JSON.stringify({
Expand Down

0 comments on commit ab6e220

Please sign in to comment.