22
33const deglob = require ( 'deglob' )
44const find = require ( 'find-file-up' )
5+ const Githost = require ( 'find-githost' )
56const engine = require ( 'unified-engine' )
67const color = require ( 'supports-color' ) . stdout
78const fromCallback = require ( 'catering' ) . fromCallback
@@ -17,7 +18,7 @@ function hallmark (options, callback) {
1718 const pkg = read ( 'package.json' , cwd ) || { }
1819 const rc = Object . assign ( { } , read ( '.hallmarkrc' , cwd ) , pkg . hallmark )
1920 const files = first ( 'files' , options , rc ) || [ '*.md' ]
20- const repository = repo ( first ( 'repository' , options , rc , pkg ) ) || originRepo ( cwd ) || ''
21+ const repository = repo ( cwd , options , rc , pkg )
2122 const ignore = concat ( 'ignore' , rc , options )
2223
2324 deglob ( files , { usePackageJson : false , cwd, ignore } , function ( err , files ) {
@@ -178,8 +179,20 @@ function first (key, ...sources) {
178179 }
179180}
180181
181- function repo ( repository ) {
182- return repository ? repository . url || repository : null
182+ function repo ( cwd , options , rc , pkg ) {
183+ const override = options . repository || rc . repository
184+ const committish = false
185+
186+ if ( override ) {
187+ return Githost . fromUrl ( override , { committish } ) . https ( )
188+ }
189+
190+ const host = (
191+ Githost . fromPkg ( pkg , { committish, optional : true } ) ||
192+ Githost . fromGit ( cwd , { committish } )
193+ )
194+
195+ return host . https ( )
183196}
184197
185198function concat ( key , rc , options ) {
@@ -192,11 +205,3 @@ function collapseToc () {
192205 summary : 'Click to expand'
193206 }
194207}
195-
196- function originRepo ( cwd ) {
197- // Don't pass cwd for now (jonschlinkert/parse-git-config#13)
198- const origin = require ( 'remote-origin-url' ) . sync ( /* cwd */ )
199- const ghurl = require ( 'github-url-from-git' )
200-
201- return origin ? ghurl ( origin ) : null
202- }
0 commit comments