Skip to content

Commit 5d419a7

Browse files
committed
fix: refactor repository to handle objects
1 parent c90daf2 commit 5d419a7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function initOpts () {
9191
prompt: {
9292
message: 'Repository:',
9393
default: (promptInput, allInput) => {
94-
return allInput.repository || git.remote({ cwd: allInput.cwd })
94+
return allInput.repository
9595
}
9696
}
9797
},
@@ -251,14 +251,26 @@ async function readPackageJson (options, { log } = {}) {
251251
author = `${pkg.author.name}${pkg.author.email ? ` <${pkg.author.email}>` : ''}`
252252
}
253253

254+
let repo
255+
if (!pkg || !pkg.repository) {
256+
const gitRemote = await git.remote({ cwd: opts.cwd })
257+
if (gitRemote) {
258+
repo = gitRemote
259+
}
260+
} else if (pkg && typeof pkg.repository === 'string') {
261+
repo = pkg.repository
262+
} else if (pkg && typeof pkg.repository !== 'undefined' && pkg.repository.url) {
263+
repo = pkg.repository.url
264+
}
265+
254266
// Set defaults from the package.json
255267
options.defaults({
256268
version: pkg.version,
257269
name: pkg.name,
258270
type: pkg.type,
259271
author: author,
260272
description: pkg.description,
261-
repository: pkg.repository,
273+
repository: repo,
262274
keywords: pkg.keywords,
263275
scripts: pkg.scripts,
264276
license: pkg.license

0 commit comments

Comments
 (0)