Skip to content

Instantly share code, notes, and snippets.

@Istar-Eldritch
Created June 17, 2016 17:54
Show Gist options
  • Save Istar-Eldritch/97d5611357db846ff0980c469ef23656 to your computer and use it in GitHub Desktop.
Save Istar-Eldritch/97d5611357db846ff0980c469ef23656 to your computer and use it in GitHub Desktop.
Add badge depending on branch
#!/usr/bin/env node
`use strict`;
const exec = require('child_process').execSync;
const fs = require('fs');
let USER = "repositive"
let REPO = "hapi-path-generator"
console.log('Starting pre-commit hook...');
let BRANCH = exec('git rev-parse --abbrev-ref HEAD');
let BADGE = `[![Build Status](https://travis-ci.org/${USER}/${REPO}.png?branch=${BRANCH})][travis]`;
let readme = fs.readFileSync(`${__dirname}/../../README.md`);
readme.replace('{{BADGE}}', BADGE);
exec('git add README.md');
print('pre-commit hook complete');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment