-
-
Save cgmartin/fe9eaeadd023a52b37c5 to your computer and use it in GitHub Desktop.
Revisions
-
cgmartin revised this gist
Jun 7, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ npm.load(function (err) { npm.commands.test(function(err) { if (err) failed('test', err); // Chain additional commands... //npm.commands['run-script'](['foo'], function(err) { // if (err) failed('foo', err); //}); -
cgmartin revised this gist
Jun 7, 2015 . 3 changed files with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,13 @@ Here's how this works: * Include a `git-hooks/` directory in your project, with these two files (plus other hooks if you want, written in a similar style). * Ensure the files under the `git-hooks/` directory are executable: `chmod 755 git-hooks/*` * Add `test` script to your `package.json`, e.g. ```json "scripts": { "test": "mocha" } ``` * Whenever you clone the repository, run `git-hooks/install-hooks` to symlink the hooks stored in the repository, in `git-hooks`, to the hidden `.git/hooks` directory. File renamed without changes.File renamed without changes. -
cgmartin revised this gist
Jun 7, 2015 . 2 changed files with 13 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ #!/usr/bin/env node var fs = require("fs"); var path = require("path"); var gitHookDir = path.resolve(__dirname, '..', '.git', 'hooks'); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,20 @@ #!/usr/bin/env node var npm = require('npm'); npm.load(function (err) { if (err) throw err; // run `npm test` npm.commands.test(function(err) { if (err) failed('test', err); //npm.commands['run-script'](['foo'], function(err) { // if (err) failed('foo', err); //}); }); }); function failed(msg, err) { console.error('\npre-commit failure:', msg, err); process.exit(1); } -
cgmartin revised this gist
Jun 7, 2015 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,20 @@ #!/usr/bin/env node var fs = require("fs"); var path = require("path"); var gitHookDir = path.resolve(__dirname, '..', '.git', 'hooks'); ["applypatch-msg", "commit-msg", "post-commit", "post-receive", "post-update", "pre-applypatch", "pre-commit", "prepare-commit-msg", "pre-rebase", "update"].forEach(function (hook) { var hookInSourceControl = path.resolve(__dirname, hook); if (fs.existsSync(hookInSourceControl)) { var hookInHiddenDirectory = path.resolve(gitHookDir, hook); if (fs.existsSync(hookInHiddenDirectory)) { fs.unlinkSync(hookInHiddenDirectory); } fs.symlinkSync(path.relative(gitHookDir, hookInSourceControl), hookInHiddenDirectory); } }); -
domenic revised this gist
Mar 29, 2012 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,11 @@ npm.load(function (err) { if (err) { process.exit(1); } npm.commands["run-script"](["lint"], function (err) { if (err) { process.exit(1); } }); }); }); -
domenic revised this gist
Mar 29, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,10 @@ var path = require("path"); ["applypatch-msg", "commit-msg", "post-commit", "post-receive", "post-update", "pre-applypatch", "pre-commit", "prepare-commit-msg", "pre-rebase", "update"].forEach(function (hook) { var hookInSourceControl = path.resolve(__dirname, hook); if (path.existsSync(hookInSourceControl)) { var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", hook); if (path.existsSync(hookInHiddenDirectory)) { fs.unlinkSync(hookInHiddenDirectory); -
domenic created this gist
Mar 29, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ Here's how this works: * Include a `git_hooks/` directory in your project, with these two files (plus other hooks if you want, written in a similar style). * Add `"npm"` to your `devDependencies` in `package.json`, so that the `pre-commit` hook can do its magic. * Add `test` and `lint` scripts to your `package.json`, e.g. ```json "scripts": { "test": "mocha", "lint": "jshint ./lib --show-non-errors" } ``` * Whenever you clone the repository, run `node git_hooks/link.js` to symlink the hooks stored in the repository, in `git_hooks`, to the hidden `.git/hooks` directory. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ var fs = require("fs"); var path = require("path"); ["applypatch-msg", "commit-msg", "post-commit", "post-receive", "post-update", "pre-applypatch", "pre-commit", "prepare-commit-msg", "pre-rebase", "update"].forEach(function (hook) { var hookInSourceControl = path.resolve(__dirname, "pre-commit"); if (path.existsSync(hookInSourceControl)) { var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", "pre-commit"); if (path.existsSync(hookInHiddenDirectory)) { fs.unlinkSync(hookInHiddenDirectory); } fs.linkSync(hookInSourceControl, hookInHiddenDirectory); } }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ #!/usr/bin/env node var npm = require("npm"); npm.load(function (err) { if (err) { throw err; } npm.commands.test(function (err) { if (err) { process.exit(1); } }); npm.commands["run-script"](["lint"], function (err) { if (err) { process.exit(1); } }); });