diff --git a/cli.js b/cli.js index 9d31cdd..8168301 100644 --- a/cli.js +++ b/cli.js @@ -38,7 +38,7 @@ if (argv.help) { const glob = argv._.length ? argv._ : ['*.md'] const pkg = getNearestPackage(cwd) || {} const packageOpts = Object.assign({}, pkg.hallmark) - const repo = pkg.repository ? pkg.repository.url || pkg.repository : '' + const repo = pkg.repository ? pkg.repository.url || pkg.repository : originRepo(cwd) || '' const ignore = [].concat(packageOpts.ignore || []).concat(argv.ignore || []) packageOpts.validateLinks = packageOpts.validateLinks !== false @@ -68,3 +68,11 @@ function getNearestPackage (cwd) { } } + +function originRepo (cwd) { + // Don't pass cwd for now (jonschlinkert/parse-git-config#13) + const origin = require('remote-origin-url').sync(/* cwd */) + const ghurl = require('github-url-from-git') + + return origin ? ghurl(origin) : null +} diff --git a/package.json b/package.json index 728fd90..aa1f056 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "deglob": "^4.0.0", "find-root": "^1.1.0", + "github-url-from-git": "^1.5.0", "markdown-extensions": "^1.1.1", "remark": "^12.0.1", "remark-changelog": "^1.0.0", @@ -41,6 +42,7 @@ "remark-lint-table-pipes": "^2.0.1", "remark-toc": "^7.0.0", "remark-validate-links": "^10.0.2", + "remote-origin-url": "^2.0.0", "subarg": "^1.0.0", "supports-color": "^7.1.0", "unified-engine": "^8.0.0"