Skip to content

Commit 758e440

Browse files
committed
Add git hooks
1 parent bcea359 commit 758e440

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@
3636
"istanbul": "latest",
3737
"mocha-fivemat-progress-reporter": "latest",
3838
"tslint": "latest",
39-
"tsd": "latest"
39+
"tsd": "latest",
40+
"npm": "^2"
4041
},
4142
"scripts": {
4243
"pretest": "jake tests",
4344
"test": "jake runtests",
4445
"build": "npm run build:compiler && npm run build:tests",
4546
"build:compiler": "jake local",
4647
"build:tests": "jake tests",
47-
"clean": "jake clean"
48+
"clean": "jake clean",
49+
"jake": "jake",
50+
"postinstall": "node scripts/link-hooks.js"
4851
},
4952
"browser": {
5053
"buffer": false,

scripts/hooks/post-checkout

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

scripts/link-hooks.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var fs = require("fs");
2+
var path = require("path");
3+
4+
var hooks = [
5+
"post-checkout"
6+
];
7+
8+
hooks.forEach(function (hook) {
9+
var hookInSourceControl = path.resolve(__dirname, "hooks", hook);
10+
11+
if (fs.existsSync(hookInSourceControl)) {
12+
var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", hook);
13+
14+
if (fs.existsSync(hookInHiddenDirectory)) {
15+
fs.unlinkSync(hookInHiddenDirectory);
16+
}
17+
18+
fs.linkSync(hookInSourceControl, hookInHiddenDirectory);
19+
}
20+
});

0 commit comments

Comments
 (0)