Skip to content

Commit

Permalink
fix: accounts dot vs dash version/license config
Browse files Browse the repository at this point in the history
Fixes a compat problem with the new `@npmcli/config` module that changes
the way these properties are handled, these aliases are no longer
auto-merged and instead live as two different properties in the new
config scheme. With that in mind this adds an extra check that validates
that the value retrieved by dot-separated property is actually different
from the default value defined in the global npm config before trying to
use that - this way users defining dash-separated configs can actually
use their values.
  • Loading branch information
ruyadorno committed Oct 9, 2020
1 parent b20020b commit c0ace81
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions default-input.js
Expand Up @@ -70,8 +70,14 @@ exports.name = yes ? name : prompt('package name', niceName(name), function (da
return er
})

const defaultDottedInitVersion = config &&
config.defaults &&
config.defaults['init.version']
const dottedInitVersion =
config.get('init.version') !== defaultDottedInitVersion &&
config.get('init.version')
var version = package.version ||
config.get('init.version') ||
dottedInitVersion ||
config.get('init-version') ||
'1.0.0'
exports.version = yes ?
Expand Down Expand Up @@ -230,8 +236,14 @@ if (!package.author) {
: yes ? '' : prompt('author')
}

const defaultDottedInitLicense = config &&
config.defaults &&
config.defaults['init.license']
const dottedInitLicense =
config.get('init.license') !== defaultDottedInitLicense &&
config.get('init.license')
var license = package.license ||
config.get('init.license') ||
dottedInitLicense ||
config.get('init-license') ||
'ISC'
exports.license = yes ? license : prompt('license', license, function (data) {
Expand Down

0 comments on commit c0ace81

Please sign in to comment.