@@ -22,16 +22,7 @@ const arrayOrUndefined = require('./lib/array-or-undefined')
2222// cpu
2323// publishConfig
2424
25- module . exports = async function createPackageJson ( options = { } ) {
26- // Construct all the options from the input
27- const opts = await buildOptions ( options )
28-
29- // Merge it back together and write it out
30- return write ( ( opts . noPrompt === true ) ? opts : await prompt ( opts , options ) , format ( opts , pkg ) )
31- }
32-
33- module . exports . buildOptions = buildOptions
34- async function buildOptions ( input = { } ) {
25+ module . exports = async function createPackageJson ( input = { } ) {
3526 // Removed undefined values from input
3627 const options = Object . keys ( input ) . reduce ( ( o , key ) => {
3728 if ( typeof input [ key ] !== 'undefined' ) {
@@ -41,7 +32,7 @@ async function buildOptions (input = {}) {
4132 } , { } )
4233
4334 // Option defaults
44- const opts = Object . assign ( {
35+ let opts = Object . assign ( {
4536 spacer : 2 ,
4637 directory : process . cwd ( ) ,
4738 ignoreExisting : false ,
@@ -60,6 +51,7 @@ async function buildOptions (input = {}) {
6051 }
6152 }
6253
54+ // Construct all the options from the input
6355 // Set things from opts, package.json or defaults
6456 opts . version = opts . version || pkg . version || '1.0.0'
6557 opts . description = opts . description || pkg . description || ''
@@ -80,7 +72,8 @@ async function buildOptions (input = {}) {
8072 opts . name = name
8173 opts . scope = scope
8274
83- return opts
75+ // Merge it back together and write it out
76+ return write ( ( opts . noPrompt === true ) ? opts : await prompt ( opts , options ) , format ( opts , pkg ) )
8477}
8578
8679module . exports . format = format
0 commit comments