diff --git a/handlebars/helpers.js b/handlebars/helpers.js index 443e11d..18af4e1 100644 --- a/handlebars/helpers.js +++ b/handlebars/helpers.js @@ -228,6 +228,29 @@ module.exports = { return githubUrl(filePath) }, + /** + * Returns the path to the github repository (below github.com) based on the $.repository.url. + * @param options + * @returns {string=} the repository path within github.com (or null) + */ + githubRepo: function(options) { + var url = null; + try { + url = options.data.root.package.repository.url + var match = url.match(/.*?(:\/\/|@)github\.com[/:](.*?)(#.*?)?$/) + if (match) { + return match[2].replace(/\.git$/, '') + } else { + return null; + } + } catch (e) { + console.log("Cannot find repository url"); + url = null + } + + console.log(url.replace("")); + }, + /** * Create a link to the npm-package of a package * @param packageName the name of the package diff --git a/handlebars/templates/README.md.hbs b/handlebars/templates/README.md.hbs index d85970e..f5efa30 100644 --- a/handlebars/templates/README.md.hbs +++ b/handlebars/templates/README.md.hbs @@ -4,8 +4,8 @@ [![NPM version](https://badge.fury.io/js/{{package.name}}.svg)](http://badge.fury.io/js/{{package.name}}) {{/unless}} {{#if ( exists '.travis.yml' ) }} -[![Build Status](https://travis-ci.org/nknapp/{{package.name}}.svg)](https://travis-ci.org/nknapp/{{package.name}}) -[![Coverage Status](https://img.shields.io/coveralls/nknapp/{{package.name}}.svg)](https://coveralls.io/r/nknapp/{{package.name}}) +[![Build Status](https://travis-ci.org/{{githubRepo}}.svg?branch=master)](https://travis-ci.org/{{githubRepo}}) +[![Coverage Status](https://img.shields.io/coveralls/{{githubRepo}}.svg)](https://coveralls.io/r/{{githubRepo}}) {{/if}} > {{{package.description}}}