Bulletproof commithook.js for accidental crashes