From 678ceecaeaf275336d7eb2a57c52b5fe4806a43d Mon Sep 17 00:00:00 2001 From: aayushRedHat Date: Thu, 14 Dec 2023 22:38:21 +0530 Subject: [PATCH] fix sonar issues --- lib/generator.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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)