diff --git a/lib/generator.js b/lib/generator.js index 8d6403eb38..dbb1a40bb6 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -99,7 +99,7 @@ class Generator { const options = arguments[arguments.length - 1]; const invalidOptions = getInvalidOptions(GENERATOR_OPTIONS, options || []); if (invalidOptions.length) throw new Error(`These options are not supported by the generator: ${invalidOptions.join(', ')}`); - if (options && options.registry) { + if (options?.registry) { const invalidRegOptions = getInvalidOptions(REGISTRY_OPTIONS, options.registry || []); invalidRegOptions(invalidOptions) } @@ -565,11 +565,13 @@ class Generator { const arbOptions = { path: ROOT_DIR, }; + if (this.registry) { - if (this.registry.url) arbOptions.registry = this.registry.url; - if (this.registry.username) arbOptions.username = this.registry.username; - if (this.registry.password) arbOptions.password = this.registry.password; - if (this.registry.token) arbOptions.token = this.registry.token; + + arbOptions.registry = this.registry.url ?? arbOptions.registry; + arbOptions.username = this.registry.username ?? arbOptions.username; + arbOptions.password = this.registry.password ?? arbOptions.password; + arbOptions.token = this.registry.token ?? arbOptions.token; } const arb = new Arborist(arbOptions)