Skip to content

Commit c0ace81

Browse files
committed
fix: accounts dot vs dash version/license config
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.
1 parent b20020b commit c0ace81

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

default-input.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ exports.name = yes ? name : prompt('package name', niceName(name), function (da
7070
return er
7171
})
7272

73+
const defaultDottedInitVersion = config &&
74+
config.defaults &&
75+
config.defaults['init.version']
76+
const dottedInitVersion =
77+
config.get('init.version') !== defaultDottedInitVersion &&
78+
config.get('init.version')
7379
var version = package.version ||
74-
config.get('init.version') ||
80+
dottedInitVersion ||
7581
config.get('init-version') ||
7682
'1.0.0'
7783
exports.version = yes ?
@@ -230,8 +236,14 @@ if (!package.author) {
230236
: yes ? '' : prompt('author')
231237
}
232238

239+
const defaultDottedInitLicense = config &&
240+
config.defaults &&
241+
config.defaults['init.license']
242+
const dottedInitLicense =
243+
config.get('init.license') !== defaultDottedInitLicense &&
244+
config.get('init.license')
233245
var license = package.license ||
234-
config.get('init.license') ||
246+
dottedInitLicense ||
235247
config.get('init-license') ||
236248
'ISC'
237249
exports.license = yes ? license : prompt('license', license, function (data) {

0 commit comments

Comments
 (0)