Last active
May 20, 2019 05:53
-
-
Save fand/2eada69b54e05ea79913 to your computer and use it in GitHub Desktop.
npmenv
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
#!/bin/bash | |
# .npmを作成 | |
if [ ! -e .npm ]; then | |
mkdir .npm | |
fi | |
# npm本体をインストール | |
NPM_VERSION=$(echo $1 || cat .npm-version || npm -v) | |
if [ ! NPM_VERSION = $(npm -v) ]; then | |
npm install -g npm@$NPM_VERSION | |
fi | |
# 依存パッケージの準備 | |
rm -rf node_modules | |
if [ -e ".npm/$NPM_VERSION" ]; then | |
# 既にインストールされていればコピーする | |
echo 'Copying installed node_modules...' | |
cp -r .npm/$NPM_VERSION node_modules | |
else | |
# なければインストールする | |
echo 'Installing deps to node_modules...' | |
npm install | |
cp -r node_modules .npm/$NPM_VERSION | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment