Code coverage report for lib/github.js

Statements: 100% (11 / 11)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (11 / 11)      Ignored: none     

All files » lib/ » github.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28    26 26 26   26 2                   26 2 2 2 2       2    
'use strict';
 
var path = require('path');
var findGit = require('../lib/git/find_git');
var getGithubURLPrefix = require('../lib/git/url_prefix');
 
function getFileRoot(file) {
  return path.dirname(findGit(file));
}
 
/**
 * Attempts to link code to its place on GitHub.
 *
 * @name linkGitHub
 * @param {Object} comment parsed comment
 * @return {Object} comment with github inferred
 */
module.exports = function (comment) {
  var root = getFileRoot(comment.context.file);
  var urlPrefix = getGithubURLPrefix(root);
  comment.context.path = comment.context.file.replace(root + '/', '');
  comment.context.github = urlPrefix +
    comment.context.file.replace(root + '/', '') +
    '#L' + comment.context.loc.start.line + '-' +
    'L' + comment.context.loc.end.line;
  return comment;
};