-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
npm install from cache fails with shrinkwrap when network is down
- Loading branch information
0 parents
commit af507c1
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
# tested on Ubuntu 12.04 | ||
# usage: | ||
# ./doit.sh | ||
# npm install from cache with shrinkwrap fails when networking is disabled | ||
# ./doit.sh noshrinkwrap | ||
# npm install from cache without shrinkwrap works when networking is disabled | ||
|
||
|
||
curl http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz | tar xvz | ||
TPATH="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
export PATH="${TPATH}/node-v0.10.28-linux-x64/bin:${NUCLEUS_HOME}/node_modules/.bin:$PATH" | ||
|
||
# i == 1: populate cache, disable networking | ||
# i == 2: try npm install with prefilled cache and NPM_CONFIG_CACHE-MIN=999999 | ||
# i == 3: try npm install with prefilled cache and NPM_CONFIG_REGISTRY="" | ||
# i == 4: try npm install with prefilled cache and NPM_CONFIG_REGISTRY=null | ||
# then enables networking back | ||
for i in $(seq 1 4); | ||
do | ||
echo "test =-= ${i}" | ||
NPM_CACHE=${TPATH}/npm_cache${i} | ||
rm -rf ${NPM_CACHE} | ||
|
||
# first iteration constructs npm cache, next iterations copy it | ||
if [ $i != 1 ]; then | ||
cp -a ${TPATH}/npm_cache1 ${NPM_CACHE} | ||
fi | ||
|
||
rm -rf test${i} | ||
mkdir -p test${i} | ||
cp package.json test${i} | ||
if [ "$1" != "noshrinkwrap" ]; then | ||
echo "cp npm-shrinkwrap.json test${i}" | ||
cp npm-shrinkwrap.json test${i} | ||
fi | ||
cd test${i} | ||
|
||
if [ "$i" == "1" ]; then | ||
E="NPM_CONFIG_CACHE=${NPM_CACHE}" | ||
E2="NPM_CONFIG_CACHE=${NPM_CACHE}" | ||
elif [ "$i" == "2" ]; then | ||
E="NPM_CONFIG_CACHE-MIN=999999" | ||
E2="NPM_CONFIG_CACHE=${NPM_CACHE}" | ||
elif [ "$i" == "3" ]; then | ||
E="NPM_CONFIG_REGISTRY=\"\"" | ||
E2="NPM_CONFIG_CACHE=${NPM_CACHE}" | ||
elif [ "$i" == "4" ]; then | ||
E="NPM_CONFIG_REGISTRY=null" | ||
E2="NPM_CONFIG_CACHE=${NPM_CACHE}" | ||
fi | ||
|
||
time env "${E}" "${E2}" npm config ls -l 2>&1 |tee out.log | ||
time env "${E}" "${E2}" npm install 2>&1 |tee -a out.log | ||
|
||
cd .. | ||
|
||
# turn networking off after the first iteration | ||
if [ "$i" == "1" ]; then | ||
sudo ifconfig eth0 down | ||
sleep 20; | ||
fi | ||
done | ||
# turn networking back on | ||
sudo ifconfig eth0 up |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "npm_offline_test", | ||
"version": "0.0.1", | ||
"description": "npm_offline_test", | ||
"dependencies": { | ||
"mkdirp": "0.5.0" | ||
} | ||
} |