0.1.1 • Published 7 years ago

git-web-hooks v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

git-web-hooks

A module for reacting to git webhooks.

NPM

Example

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.

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, forever, pm2, or others.

nohup your-hook-server.js &

forever start your-hook-server.js

pm2 start your-hook-server.js

0.1.1

7 years ago

0.1.0

7 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago