From 70fe18fc3e532084a637bd229751da134164acbe Mon Sep 17 00:00:00 2001 From: Guido Longoni Date: Thu, 22 Jan 2026 14:12:50 +0100 Subject: [PATCH] policy nodejs con npm-check-updates --- featlib/npm.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/featlib/npm.sh b/featlib/npm.sh index 762f7dc..1c2cbd2 100755 --- a/featlib/npm.sh +++ b/featlib/npm.sh @@ -29,6 +29,7 @@ function feat_add_npm() { mkdir -p "$N_PREFIX" curl -L https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s latest npm install -g n + npm install -g npm-check-updates } function npm_initialized() { @@ -47,6 +48,18 @@ function npm_feat_missing() { npm list 2>&1 | grep -q 'missing[^ ]* *'"$FEAT"'@' } +function npm_feat_ensure_ncu() { + if feat_missing "ncu"; then + npm install -g npm-check-updates + fi +} + +function npm_feat_update_latest() { + npm_feat_ensure_ncu + ncu -u + npm install +} + function npm-g_feat_add() { npm install -g npm npm install -g "$1" @@ -60,20 +73,18 @@ function npm_feat_add() { function npm_feat_needed() { feat_needed "npm" FEAT="$1" + npm_feat_ensure_ncu if ! npm_initialized; then npm init -y fi - if npm_feat_added "$FEAT"; then - if npm_feat_missing "$FEAT"; then - npm install - fi - else + if ! npm_feat_added "$FEAT"; then if type "npm_feat_add_$FEAT" > /dev/null 2>&1 ; then eval "npm_feat_add_$FEAT" else npm_feat_add "$FEAT" fi fi + npm_feat_update_latest } function npm-g_feat_needed() {