Skip to content

Commit b786687

Browse files
committed
Merge pull request microsoft#4961 from weswigham/repo-hooks
Git post-checkout hook
2 parents bcea359 + 29f7c2c commit b786687

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"build": "npm run build:compiler && npm run build:tests",
4545
"build:compiler": "jake local",
4646
"build:tests": "jake tests",
47-
"clean": "jake clean"
47+
"clean": "jake clean",
48+
"jake": "jake",
49+
"postinstall": "node scripts/link-hooks.js"
4850
},
4951
"browser": {
5052
"buffer": false,

scripts/hooks/post-checkout

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
npm run jake -- generate-diagnostics

scripts/link-hooks.js

Lines changed: 20 additions & 0 deletions
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)