How do you handle very long NPM scripts?
My NPM scripts are getting very long, for example if I'd like to kill all docker containers of my project, remove images and volumes and rebuild everything form scratch it goes like this:
docker ps | grep my_project | tr -s ' ' | cut -d ' ' -f2 | xargs docker kill &&
docker images | grep my_project | tr -s ' ' | cut -d ' ' -f2 | xargs docker rmi -f &&
docker volume ls | tr -s ' ' | cut -d ' ' -f2 |xargs docker volume rm &&
docker-compose rm -f &&
docker-compose build &&
docker-compose up
That's way to much for one line. I'm thinking about moving this code to separate .sh file and point NPM to execute that file. What do you think about that? What are your solutions?