diff --git a/lib/commands/view.js b/lib/commands/view.js index 0c3f232602f87..6d81968207629 100644 --- a/lib/commands/view.js +++ b/lib/commands/view.js @@ -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 diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 4d584346d0f3b..5fa361efcd3da 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -199,12 +199,7 @@ module.exports = (er, npm) => { const valResult = nameValidator(pkg) - if (valResult.validForNewPackages) { - detail.push([ - '404', - 'You should bug the author to publish it (or use the name yourself!)', - ]) - } else { + if (!valResult.validForNewPackages) { detail.push(['404', 'This package name is not valid, because', '']) const errorsArray = [...(valResult.errors || []), ...(valResult.warnings || [])] diff --git a/tap-snapshots/test/lib/utils/error-message.js.test.cjs b/tap-snapshots/test/lib/utils/error-message.js.test.cjs index 3b82e3c055de6..6316f04fd0998 100644 --- a/tap-snapshots/test/lib/utils/error-message.js.test.cjs +++ b/tap-snapshots/test/lib/utils/error-message.js.test.cjs @@ -155,10 +155,6 @@ Object { "", "'yolo' is not in this registry.", ], - Array [ - "404", - "You should bug the author to publish it (or use the name yourself!)", - ], Array [ "404", String( diff --git a/test/lib/commands/view.js b/test/lib/commands/view.js index 035490a79fbf7..e49133dad0688 100644 --- a/test/lib/commands/view.js +++ b/test/lib/commands/view.js @@ -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: { @@ -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' } ) })