Skip to content

Instantly share code, notes, and snippets.

@AnatolyRugalev
Last active August 27, 2015 07:17
Show Gist options
  • Save AnatolyRugalev/c82d46c44b5e74a7e511 to your computer and use it in GitHub Desktop.
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
#/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
@AnatolyRugalev
Copy link
Author

NPM version is 1.4.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment