diff --git a/src/commands/unlock.command.ts b/src/commands/unlock.command.ts index 34f1ef109b..03fa73d7eb 100644 --- a/src/commands/unlock.command.ts +++ b/src/commands/unlock.command.ts @@ -18,19 +18,17 @@ import { NodeUtils } from 'jslib-common/misc/nodeUtils'; import { ConsoleLogService } from 'jslib-common/services/consoleLog.service'; export class UnlockCommand { - private logService: ConsoleLogService; - constructor(private cryptoService: CryptoService, private userService: UserService, - private cryptoFunctionService: CryptoFunctionService, private apiService: ApiService) { - this.logService = new ConsoleLogService(false); + private cryptoFunctionService: CryptoFunctionService, private apiService: ApiService, + private logService: ConsoleLogService) { } async run(password: string, options: program.OptionValues) { const canInteract = process.env.BW_NOINTERACTION !== 'true'; if (password == null || password === '') { - if (options.passwordfile) { + if (options?.passwordfile) { password = await NodeUtils.readFirstLine(options.passwordfile); - } else if (options.passwordenv) { + } else if (options?.passwordenv) { if (process.env[options.passwordenv]) { password = process.env[options.passwordenv]; } else { diff --git a/src/program.ts b/src/program.ts index 4787e55c3c..4e1666b4f8 100644 --- a/src/program.ts +++ b/src/program.ts @@ -208,7 +208,7 @@ export class Program extends BaseProgram { if (!cmd.check) { await this.exitIfNotAuthed(); const command = new UnlockCommand(this.main.cryptoService, this.main.userService, - this.main.cryptoFunctionService, this.main.apiService); + this.main.cryptoFunctionService, this.main.apiService, this.main.logService); const response = await command.run(password, cmd); this.processResponse(response); } @@ -412,7 +412,7 @@ export class Program extends BaseProgram { const canInteract = process.env.BW_NOINTERACTION !== 'true'; if (canInteract) { const command = new UnlockCommand(this.main.cryptoService, this.main.userService, - this.main.cryptoFunctionService, this.main.apiService); + this.main.cryptoFunctionService, this.main.apiService, this.main.logService); const response = await command.run(null, null); if (!response.success) { this.processResponse(response, true);