Created
February 27, 2013 22:01
-
-
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.
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 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