I have a gulp task that runs a minification of several files, and it works perfectly when I run the command gulp minify from the command line. What I'm trying to do is to run this command automatically on pre-commit, but the minified files are not generated. I've installed pre-commit hook of npm, and I'm basically doing something similar to what's presented in this article:
http://x-team.com/2014/11/fearless-development-cycle-git-hooks/
This is part of my package.json:
"devDependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-minify-css": "^1.2.3",
"gulp-uglify": "^1.5.1",
"precommit-hook": "^3.0.0"
},
"scripts": {
"start": "node server.js",
"minify": "gulp minify"
},
"pre-commit": [
"minify"
]
I've tried both "pre-commit" and "precommit" in my package.json, no difference.
It does not go in your package.json. You need to add a file called pre-commit under .git/hooks directory.
#!/bin/bash
gulp minify
Also make sure the pre-commit file is executable. Run this:
chmod +x pre-commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With