Last active
December 12, 2015 03:59
-
-
Save matthewhudson/4711219 to your computer and use it in GitHub Desktop.
A pre-commit hook to minify JavaScript files and add them to staging.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var fs = require('fs'); | |
var uglify = require('uglify-js'); | |
var path = require('path'); | |
var exec = require('child_process').exec; | |
var in_file = path.normalize(__dirname + '../../../infile.js'); | |
var out_file = path.normalize(__dirname + '../../../outfile.min.js'); | |
var result = uglify.minify(in_file); | |
fs.writeFile(out_file, result.code, function (err) { | |
if (err) return console.warn(err); | |
console.log('Successfully created ' + out_file); | |
}); | |
exec('git add ' + out_file, function (err, stdout, stderr) { | |
if (err) return console.warn(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment