From 2f3b79bbad820fd4a398aa494b19f79b7fd520a1 Mon Sep 17 00:00:00 2001 From: claudiahdz Date: Fri, 9 Aug 2019 16:40:59 -0500 Subject: [PATCH] feat: add new forbidden 403 error code PR-URL: https://github.com/npm/cli/pull/234 Credit: @claudiahdz Close: #234 Reviewed-by: @isaacs --- lib/outdated.js | 2 +- lib/utils/error-message.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/outdated.js b/lib/outdated.js index bb4c346f9a654..794197cfc6a69 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -421,7 +421,7 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, opts, cb, type var l = pickManifest(d, 'latest') var m = pickManifest(d, req) } catch (er) { - if (er.code === 'ETARGET') { + if (er.code === 'ETARGET' || er.code === 'E403') { return skip(er) } else { return skip() diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 7835a1cdfcfa2..5ddfb37682a2e 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -327,6 +327,18 @@ function errorMessage (er) { detail.push(['notarget', msg.join('\n')]) break + case 'E403': + short.push(['403', er.message]) + msg = [ + 'In most cases, you or one of your dependencies are requesting', + 'a package version that is forbidden by your security policy.' + ] + if (er.parent) { + msg.push("\nIt was specified as a dependency of '" + er.parent + "'\n") + } + detail.push(['403', msg.join('\n')]) + break + case 'ENOTSUP': if (er.required) { short.push(['notsup', er.message])