Skip to content

Commit

Permalink
Fallback to git remote to get repository url
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Oct 15, 2020
1 parent 2807d17 commit dbbe165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit dbbe165

Please sign in to comment.