Skip to content

Commit

Permalink
Add git hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Sep 25, 2015
1 parent bcea359 commit 758e440
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@
"istanbul": "latest",
"mocha-fivemat-progress-reporter": "latest",
"tslint": "latest",
"tsd": "latest"
"tsd": "latest",
"npm": "^2"
},
"scripts": {
"pretest": "jake tests",
"test": "jake runtests",
"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,
Expand Down
2 changes: 2 additions & 0 deletions scripts/hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions scripts/link-hooks.js
Original file line number Diff line number Diff line change
@@ -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);
}
});

0 comments on commit 758e440

Please sign in to comment.