Skip to content

Commit

Permalink
fix: remove validation for type field, and sort on save
Browse files Browse the repository at this point in the history
  • Loading branch information
reggi committed Nov 27, 2024
1 parent 8bcfcbd commit c06f040
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions lib/default-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,7 @@ exports.license = yes ? license : prompt('license', license, (data) => {
return invalid(`Sorry, ${errors.join(' and ')}.`)
})

function validateType (type) {
if (['commonjs', 'module'].includes(type)) {
return type
}
throw new Error(`${type} is not a valid package "type" (must be "commonjs" or "module")`)
}
const type = package.type || getConfig('type') || 'commonjs'
exports.type = yes ? validateType(type) : prompt('type', type, (data) => {
try {
return validateType(data)
} catch (e) {
return invalid(e.message)
}
exports.type = yes ? type : prompt('type', type, (data) => {
return data
})
2 changes: 1 addition & 1 deletion lib/init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function init (dir,
return
}

await pkg.save()
await pkg.save({ sort: true })
return pkg.content
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": "ISC",
"description": "A node module to get your node module started",
"dependencies": {
"@npmcli/package-json": "^6.0.0",
"@npmcli/package-json": "^6.1.0",
"npm-package-arg": "^12.0.0",
"promzard": "^2.0.0",
"read": "^4.0.0",
Expand Down

0 comments on commit c06f040

Please sign in to comment.