Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to test npm i, npm ci, yarn and pnpm. With and without cache. Also, without lock files and existing node_modules too.
#!/bin/bash
rm -rf node_modules/
npm cache clear --force
npm i
i="0"
echo "npm i - without cache" >> npmbg7
while [ $i -lt 7 ]
do
npm cache clear --force
rm -rf node_modules/
npm i | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm i ${1}"
done
npm cache clear --force
rm -rf node_modules/
npm ci
i="0"
echo "npm ci - without cache" >> npmbg7
while [ $i -lt 7 ]
do
npm cache clear --force
rm -rf node_modules/
npm ci | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm ci ${1}"
done
yarn cache clean
rm -rf yarn_cache/
rm -rf node_modules/
yarn --cache-folder ./yarn_cache
i="0"
echo "yarn - without cache" >> npmbg7
while [ $i -lt 7 ]
do
yarn cache clean
rm -rf yarn_cache/
rm -rf node_modules/
yarn --cache-folder ./yarn_cache | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done yarn ${1}"
done
npm cache clear --force
rm -rf node_modules/
rm -rf store/
pnpm i --store store
i="0"
echo "pnpm - without cache" >> npmbg7
while [ $i -lt 7 ]
do
npm cache clear --force
rm -rf node_modules/
rm -rf store/
pnpm i --store store | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done pnpm ${1}"
done
rm -rf node_modules/
npm i
i="0"
echo "npm i - with cache" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
npm i | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm i ${1}"
done
rm -rf node_modules/
npm ci
i="0"
echo "npm ci - with cache" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
npm ci | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm ci ${1}"
done
rm -rf node_modules/
yarn --cache-folder ./yarn_cache
i="0"
echo "yarn - with cache" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
yarn | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done yarn ${1}"
done
rm -rf node_modules/
rm -rf store/
pnpm install pnpm i --store store
i="0"
echo "pnpm - with cache" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
pnpm i --store store | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done pnpm ${1}"
done
rm -rf node_modules/
npm i
i="0"
echo "npm i - without lock file" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
rm package-lock.json
npm i | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm i ${1}"
done
rm -rf node_modules/
yarn
i="0"
echo "yarn - without lock file" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
rm yarn.lock
yarn | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done yarn ${1}"
done
rm -rf node_modules/
rm -rf store/
pnpm install --store store
i="0"
echo "pnpm - without shrinkwrap file" >> npmbg7
while [ $i -lt 7 ]
do
rm -rf node_modules/
rm -rf store/
rm shrinkwrap.yaml
pnpm i --store store | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done pnpm ${1}"
done
rm -rf node_modules/
npm i
i="0"
echo "npm i - with existing node modules" >> npmbg7
while [ $i -lt 7 ]
do
npm i | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm i ${1}"
done
rm -rf node_modules/
npm ci
i="0"
echo "npm ci - with existing node modules" >> npmbg7
while [ $i -lt 7 ]
do
npm ci | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done npm ci ${1}"
done
rm -rf node_modules/
yarn
i="0"
echo "yarn - with existing node modules" >> npmbg7
while [ $i -lt 7 ]
do
yarn | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done yarn ${1}"
done
rm -rf node_modules/
rm -rf store/
pnpm install --store store
i="0"
echo "pnpm - with existing node modules" >> npmbg7
while [ $i -lt 7 ]
do
pnpm i --store store | gnomon | tail -1 >> npmbg7
i=$[$i+1]
echo "done pnpm ${1}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.