Skip to content

Commit 28d51fc

Browse files
ikokostyatmcw
authored andcommitted
Fix github link generation for Node.js 6 (#524)
In Node.js 6 additional assertions was added in path module: nodejs/node#5348
1 parent 0a97e0e commit 28d51fc

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/git/find_git.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var fs = require('fs');
77
* Given a full path to a single file, iterate upwards through the filesystem
88
* to find a directory with a .git file indicating that it is a git repository
99
* @param {string} filename any file within a repository
10-
* @returns {string} repository path
10+
* @returns {string|undefined} repository path
1111
*/
1212
function findGit(filename) {
1313
var paths = filename.split(path.sep);

lib/github.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ var getGithubURLPrefix = require('../lib/git/url_prefix');
1212
* @return {Object} comment with github inferred
1313
*/
1414
module.exports = function (comment) {
15-
var root = path.dirname(findGit(comment.context.file));
15+
var repoPath = findGit(comment.context.file);
16+
var root = repoPath ? path.dirname(repoPath) : '.';
1617
var urlPrefix = getGithubURLPrefix(root);
1718
var fileRelativePath = comment.context.file.replace(root + path.sep, '')
1819
.split(path.sep)

0 commit comments

Comments
 (0)