From 28d51fcaf8da8e8c4c77e541904ab598fb93b9bc Mon Sep 17 00:00:00 2001 From: ikokostya Date: Sun, 4 Sep 2016 23:41:06 +0300 Subject: [PATCH] Fix github link generation for Node.js 6 (#524) In Node.js 6 additional assertions was added in path module: https://github.com/nodejs/node/pull/5348 --- lib/git/find_git.js | 2 +- lib/github.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/git/find_git.js b/lib/git/find_git.js index d12fed022..097ac2c4d 100644 --- a/lib/git/find_git.js +++ b/lib/git/find_git.js @@ -7,7 +7,7 @@ var fs = require('fs'); * Given a full path to a single file, iterate upwards through the filesystem * to find a directory with a .git file indicating that it is a git repository * @param {string} filename any file within a repository - * @returns {string} repository path + * @returns {string|undefined} repository path */ function findGit(filename) { var paths = filename.split(path.sep); diff --git a/lib/github.js b/lib/github.js index c7e178fe7..0e7a7ed6f 100644 --- a/lib/github.js +++ b/lib/github.js @@ -12,7 +12,8 @@ var getGithubURLPrefix = require('../lib/git/url_prefix'); * @return {Object} comment with github inferred */ module.exports = function (comment) { - var root = path.dirname(findGit(comment.context.file)); + var repoPath = findGit(comment.context.file); + var root = repoPath ? path.dirname(repoPath) : '.'; var urlPrefix = getGithubURLPrefix(root); var fileRelativePath = comment.context.file.replace(root + path.sep, '') .split(path.sep)