Skip to content

Commit

Permalink
Fix for travis and Coveralls badges
Browse files Browse the repository at this point in the history
- Derive URL for Travis-badge and Coveralls from github-repo-name.
- Make badge show the status of the master branch
  • Loading branch information
Nils Knappmeier committed Jan 27, 2016
1 parent 4857c6e commit fd46555
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions handlebars/helpers.js
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions handlebars/templates/README.md.hbs
Expand Up @@ -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}}}
Expand Down

0 comments on commit fd46555

Please sign in to comment.