Copyright (c) 2019 Roy Surjano. All rights reserved. This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>. npmInstallAll() { PKG=$1 PKGV="$PKG@" # echo $PKGV npmpkg=$(npm view $1 versions /| sed '/next/d' |\ sed '/beta/d' |\ sed '/-/d' |\ sed '/--/d' |\ sed '/rc/d' |\ sed '/-a/d' |\ sed '/-b/d' |\ sed '/-c/d' |\ sed '/-d/d' |\ sed '/-e/d' |\ sed '/]/d' | sed '/RC/d' |\ sed '/\[/d' |\ cut -c4-10 |\ sed -r 's/[,]+//g' |\ sed "s/'//g" |\ awk -v p=$PKGV '$0=p$0' \ ) for i in $npmpkg; do npm i $i --no-save --dry-run done } # Usage: # # npmInstallAll [package-name] # npmInstallAll @angular/core