Skip to content

Instantly share code, notes, and snippets.

@joelongstreet
Created February 27, 2013 22:01
Show Gist options
  • Save joelongstreet/5052198 to your computer and use it in GitHub Desktop.
Save joelongstreet/5052198 to your computer and use it in GitHub Desktop.
Drop this script into your git post-commit hook to take a picture of your face (or butt) every time you make a commit.
#!/usr/bin/env node
var picsPath = process.env['HOME'] + '/.gitshots/';
var imagesnap = require('imagesnap');
var fs = require('fs');
var path = require('path');
var commitPath = picsPath + new Date().getTime();
fs.mkdirParent = function(dirPath, mode, callback) {
fs.mkdir(dirPath, mode, function(error) {
if (error && error.errno === 34) {
fs.mkdirParent(path.dirname(dirPath), mode, callback);
fs.mkdirParent(dirPath, mode, callback);
}
callback && callback(error);
});
};
fs.mkdirParent(commitPath, 0777, function(){
var imageStream = fs.createWriteStream(commitPath + '/capture.jpg')
var messagePath = __dirname.replace('hooks', '');
fs.readFile(messagePath + 'COMMIT_EDITMSG', 'utf8', function(err, data){
fs.writeFile(commitPath + '/message.txt', data, function(err){
if(err) { console.log(err); }
});
imagesnap().pipe(imageStream);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment