Skip to content

Commit 574ef8e

Browse files
committed
never trust a 0.0.1
1 parent e33fedd commit 574ef8e

4 files changed

Lines changed: 316 additions & 321 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
text/fixtures/tmp
2+
test/fixtures/tmp

index.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8679
module.exports.format = format

0 commit comments

Comments
 (0)