https://github.com/positlabs/git-web-hooks
React to git hooks.
https://github.com/positlabs/git-web-hooks
developer-tools git-hooks
Last synced: about 2 months ago
JSON representation
React to git hooks.
- Host: GitHub
- URL: https://github.com/positlabs/git-web-hooks
- Owner: positlabs
- License: mit
- Created: 2016-05-10T17:52:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-21T21:53:45.000Z (over 8 years ago)
- Last Synced: 2024-10-19T07:06:47.185Z (7 months ago)
- Topics: developer-tools, git-hooks
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-web-hooks
A module for reacting to [git webhooks](https://developer.github.com/webhooks/).[](https://npmjs.org/package/git-web-hooks)
**Example**
```javascript
const GitWebhooks = require('git-web-hooks')new GitWebhooks({
PORT: 3333 // optional. 3333 is default
}).on('payload', (req, res, payload) => {
// do something based on payload contents
// then send a response to github
res.end('got it!')})
```
**Commands**
Doing something useful with the webhooks probably means you will run some commands. `GitWebhooks.command` is a thin wrapper around `child_process.exec` that returns a promise. You can use this to run commands like `git pull` or `npm install`.
```javascript
var cmd = GitWebhooks.command('echo "running a command now!"')
// it's a Promise!
cmd.then(std => {
console.log(std.out, std.err)
}).catch(err => console.error)// and you can pass options to child_process.exec
GitWebhooks.command('echo "Hello, options!"', {maxBuffer: 1024*1024})```
**Daemonize**
To keep the process alive, you should use a daemonizer like [nohup](https://en.wikipedia.org/wiki/Nohup), [forever](https://www.npmjs.com/package/forever), [pm2](https://github.com/Unitech/pm2), or others.
`nohup your-hook-server.js &`
`forever start your-hook-server.js`
`pm2 start your-hook-server.js`