Skip to content

Commit

Permalink
fix: remove name from unpublished message
Browse files Browse the repository at this point in the history
It is no longer returned from the npm registry
  • Loading branch information
wraithgar authored and nlf committed Mar 17, 2022
1 parent f95396a commit f0c6e86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/commands/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class View extends BaseCommand {

if (pckmnt.time && pckmnt.time.unpublished) {
const u = pckmnt.time.unpublished
const er = new Error('Unpublished by ' + u.name + ' on ' + u.time)
const er = new Error(`Unpublished on ${u.time}`)
er.statusCode = 404
er.code = 'E404'
er.pkgid = pckmnt._id
Expand Down
7 changes: 5 additions & 2 deletions test/lib/commands/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ const packument = (nv, opts) => {

const mocks = {
red: {
_id: 'red@1.0.1',
name: 'red',
'dist-tags': {
'1.0.1': {},
},
time: {
unpublished: new Date(),
unpublished: {
time: '2012-12-20T00:00:00.000Z',
},
},
},
blue: {
Expand Down Expand Up @@ -533,7 +536,7 @@ t.test('throws when unpublished', async t => {
const view = new View(npm)
await t.rejects(
view.exec(['red']),
{ code: 'E404' }
{ code: 'E404', pkgid: 'red@1.0.1', message: 'Unpublished on 2012-12-20T00:00:00.000Z' }
)
})

Expand Down

0 comments on commit f0c6e86

Please sign in to comment.