Skip to content

Instantly share code, notes, and snippets.

@loopmode
Last active September 28, 2023 09:11
Show Gist options
  • Save loopmode/866c3694ef32a803d5a022cdf6409d6c to your computer and use it in GitHub Desktop.
Save loopmode/866c3694ef32a803d5a022cdf6409d6c to your computer and use it in GitHub Desktop.
nuke: getting rid of stuff
# just delete all node_modules recursively without reinstalling
alias delete-node-modules='find . -name node_modules -type d -exec rm -rf "{}" + '
# delete all node_modules and reinstall via npm
nuke-npm() {
if [ "$1" == "-f" ]; then
rm -f package-lock.json
fi
find . -name node_modules -type d -exec rm -rf "{}" +
npm install
}
# delete all node_modules recursively and reinstall via yarn
nuke-yarn() {
if [ "$1" == "-f" ] ; then
rm -f yarn.lock
fi
find . -name node_modules -type d -exec rm -rf "{}" +
yarn install
}
# delete all node_modules recursively and reinstall via pnpm
nuke-pnpm() {
if [ "$1" == "-f" ] ; then
rm -f pnpm-lock.yaml
fi
find . -name node_modules -type d -exec rm -rf "{}" +
pnpm install
}
function nuke-ts() {
#? delete typescript incremental build artifacts
find . -name "*.tsbuildinfo" -type f -exec rm -rf "{}" +
#? delete regular compiled/transpiled artifacts.
#? change "dist" to whatever folder your build commands create (e.g. "build")
find . -name "dist" -type d -not -path "node_modules/*" -exec rm -rf "{}" +
}
function nuke-turbo() {
#? remove turborepo caches and artifacts
find . -name .turbo -type d -exec rm -rf "{}" +
rm -rf node_modules/.cache/turbo
}
# make my turbo monorepo fresh and clean!
alias nukem='nuke-turbo && nuke-ts && nuke-pnpm'
# stop and remove all docker containers and images
nuke-docker() {
docker stop $(docker ps -aq)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q) -f
}
alias nuke-git='rm -rf ./.git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment