Is it feasible to intercept the exit signal of an npm script?
"scripts": {
"serve": "docker-compose up && npm start"
}
I am interested in implementing docker-compose down
when terminating the script using ctrl+c
In a shell script, this can be achieved by 'trapping' the signal for exiting with 0
#!/bin/bash
trap 'docker-compose down ; echo Stopped ; exit 0' SIGINT
docker-compose up &
npm start
done
I prefer to avoid using a shell script so that the script can run on non-Unix operating systems as well.