Add git hooks

This commit is contained in:
Wesley Wigham 2015-09-24 17:00:27 -07:00
parent bcea3594a3
commit 758e4402da
3 changed files with 27 additions and 2 deletions

View file

@ -36,7 +36,8 @@
"istanbul": "latest",
"mocha-fivemat-progress-reporter": "latest",
"tslint": "latest",
"tsd": "latest"
"tsd": "latest",
"npm": "^2"
},
"scripts": {
"pretest": "jake tests",
@ -44,7 +45,9 @@
"build": "npm run build:compiler && npm run build:tests",
"build:compiler": "jake local",
"build:tests": "jake tests",
"clean": "jake clean"
"clean": "jake clean",
"jake": "jake",
"postinstall": "node scripts/link-hooks.js"
},
"browser": {
"buffer": false,

View file

@ -0,0 +1,2 @@
#!/bin/sh
echo "var npm = require("npm"); npm.load(function (err) {if (err) { throw err; } npm.commands.run(['jake', 'generate-diagnostics']); )" | node

20
scripts/link-hooks.js Normal file
View file

@ -0,0 +1,20 @@
var fs = require("fs");
var path = require("path");
var hooks = [
"post-checkout"
];
hooks.forEach(function (hook) {
var hookInSourceControl = path.resolve(__dirname, "hooks", hook);
if (fs.existsSync(hookInSourceControl)) {
var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", hook);
if (fs.existsSync(hookInHiddenDirectory)) {
fs.unlinkSync(hookInHiddenDirectory);
}
fs.linkSync(hookInSourceControl, hookInHiddenDirectory);
}
});