Skip to content

Instantly share code, notes, and snippets.

@ggirou
Created February 1, 2017 21:38
Show Gist options
  • Save ggirou/a20d862ff02c53b51921e85e46c359be to your computer and use it in GitHub Desktop.
Save ggirou/a20d862ff02c53b51921e85e46c359be to your computer and use it in GitHub Desktop.
Githooks
#!/usr/bin/env node
const fs = require('fs');
const readline = require('readline');
const commitFile = process.argv[2];
const fromIDE = !process.stdout.isTTY;
if (fromIDE) {
process.exit(0);
}
const input = fs.createReadStream('/dev/tty');
const rl = readline.createInterface({
input: input,
output: process.stdout
});
rl.question('What do you think of Node.js? ', function (answer) {
rl.close();
input.close();
var message = fs.readFileSync(commitFile);
message = answer + "\n" + message;
fs.writeFileSync(commitFile, message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment