Skip to content

Instantly share code, notes, and snippets.

@rsurjano
Last active December 9, 2019 14:00
Show Gist options
  • Save rsurjano/3aea3825efc0e9805f7feaf4e57d6b09 to your computer and use it in GitHub Desktop.
Save rsurjano/3aea3825efc0e9805f7feaf4e57d6b09 to your computer and use it in GitHub Desktop.
Verdaccio Script for caching npm packages
registry=http://localhost:4873
registry "http://localhost:4873"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment