Skip to content

Commit f0c6e86

Browse files
wraithgarnlf
authored andcommitted
fix: remove name from unpublished message
It is no longer returned from the npm registry
1 parent f95396a commit f0c6e86

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/commands/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class View extends BaseCommand {
208208

209209
if (pckmnt.time && pckmnt.time.unpublished) {
210210
const u = pckmnt.time.unpublished
211-
const er = new Error('Unpublished by ' + u.name + ' on ' + u.time)
211+
const er = new Error(`Unpublished on ${u.time}`)
212212
er.statusCode = 404
213213
er.code = 'E404'
214214
er.pkgid = pckmnt._id

test/lib/commands/view.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ const packument = (nv, opts) => {
3232

3333
const mocks = {
3434
red: {
35+
_id: 'red@1.0.1',
3536
name: 'red',
3637
'dist-tags': {
3738
'1.0.1': {},
3839
},
3940
time: {
40-
unpublished: new Date(),
41+
unpublished: {
42+
time: '2012-12-20T00:00:00.000Z',
43+
},
4144
},
4245
},
4346
blue: {
@@ -533,7 +536,7 @@ t.test('throws when unpublished', async t => {
533536
const view = new View(npm)
534537
await t.rejects(
535538
view.exec(['red']),
536-
{ code: 'E404' }
539+
{ code: 'E404', pkgid: 'red@1.0.1', message: 'Unpublished on 2012-12-20T00:00:00.000Z' }
537540
)
538541
})
539542

0 commit comments

Comments
 (0)