Last active
August 27, 2015 07:17
-
-
Save AnatolyRugalev/c82d46c44b5e74a7e511 to your computer and use it in GitHub Desktop.
npm install command by default is slow even if all packages are already installed. This script was used on CI server to install actual packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
PACKAGES_TO_INSTALL=$( npm list --depth=0 2>&1 > /dev/null | grep "ERR! missing" -c ) | |
PACKAGES_TO_PRUNE=$( npm list --depth=0 2>&1 > /dev/null | grep "ERR! extraneous" -c ) | |
if [ ${PACKAGES_TO_PRUNE} != "0" ] | |
then | |
echo "Prune ${PACKAGES_TO_PRUNE} NPM package(s)..." | |
npm prune | |
fi | |
if [ ${PACKAGES_TO_INSTALL} != "0" ] | |
then | |
echo "Install ${PACKAGES_TO_INSTALL} NPM package(s)..." | |
npm install | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NPM version is 1.4.21