Skip to content

Commit c90daf2

Browse files
committed
fix: default git user if we cannot find a default in the package.json
1 parent b413ea8 commit c90daf2

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
@@ -82,7 +82,7 @@ function initOpts () {
8282
prompt: {
8383
message: 'Author:',
8484
default: (promptInput, allInput) => {
85-
return allInput.author || git.author({ cwd: allInput.cwd })
85+
return allInput.author
8686
}
8787
}
8888
},
@@ -239,12 +239,24 @@ async function readPackageJson (options, { log } = {}) {
239239
// ignore if missing or unreadable
240240
}
241241

242+
let author
243+
if (!pkg || !pkg.author) {
244+
const gitAuthor = await git.author({ cwd: opts.cwd })
245+
if (gitAuthor) {
246+
author = gitAuthor
247+
}
248+
} else if (pkg && typeof pkg.author === 'string') {
249+
author = pkg.author
250+
} else if (pkg && typeof pkg.author !== 'undefined') {
251+
author = `${pkg.author.name}${pkg.author.email ? ` <${pkg.author.email}>` : ''}`
252+
}
253+
242254
// Set defaults from the package.json
243255
options.defaults({
244256
version: pkg.version,
245257
name: pkg.name,
246258
type: pkg.type,
247-
author: pkg.author,
259+
author: author,
248260
description: pkg.description,
249261
repository: pkg.repository,
250262
keywords: pkg.keywords,

0 commit comments

Comments
 (0)