Skip to content
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

fix(pack): detect unresolved package properly #3133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pack.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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