Skip to content

Commit 95a1f02

Browse files
committed
Fix incorrect IP check condition in getDeviceIp function #1468 #1464
1 parent 081ea53 commit 95a1f02

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/PathHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class PathHelper {
101101
await fd.close();
102102
return true;
103103
} catch (err: unknown) {
104-
if (err instanceof Error && 'code' in err && err.code === 'EEXIST') {
104+
if (err instanceof Error && "code" in err && err.code === "EEXIST") {
105105
return false;
106106
}
107107
throw err;

src/program.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,12 @@ function setupScanParameters(commandName: string) {
171171
);
172172
}
173173

174-
async function getDeviceIp(options: ProgramOption, configFile: FileConfig) {
174+
async function getDeviceIp(
175+
options: ProgramOption,
176+
configFile: FileConfig,
177+
): Promise<string> {
175178
let ip = getOptConfiguredValue(options.address, configFile.ip);
176-
if (ip !== undefined) {
179+
if (ip === undefined) {
177180
const name = getConfiguredValue(
178181
options.name,
179182
configFile.name,
@@ -465,9 +468,7 @@ function createListenCliCmd(configFile: FileConfig) {
465468
.action(async (_, cmd) => {
466469
const options = cmd.optsWithGlobals();
467470
const ip = await getDeviceIp(options, configFile);
468-
if (ip !== undefined) {
469-
HPApi.setDeviceIP(ip);
470-
}
471+
HPApi.setDeviceIP(ip);
471472

472473
const isDebug = getIsDebug(options, configFile);
473474
HPApi.setDebug(isDebug);
@@ -566,9 +567,7 @@ function createAdfAutoscanCliCmd(fileConfig: FileConfig) {
566567
const options = cmd.optsWithGlobals();
567568

568569
const ip = await getDeviceIp(options, fileConfig);
569-
if (ip !== undefined) {
570-
HPApi.setDeviceIP(ip);
571-
}
570+
HPApi.setDeviceIP(ip);
572571

573572
const isDebug = getIsDebug(options, fileConfig);
574573
HPApi.setDebug(isDebug);
@@ -643,9 +642,7 @@ function createSingleScanCliCmd(fileConfig: FileConfig) {
643642
const options = cmd.optsWithGlobals();
644643

645644
const ip = await getDeviceIp(options, fileConfig);
646-
if (ip !== undefined) {
647-
HPApi.setDeviceIP(ip);
648-
}
645+
HPApi.setDeviceIP(ip);
649646

650647
const isDebug = getIsDebug(options, fileConfig);
651648
HPApi.setDebug(isDebug);
@@ -692,9 +689,7 @@ function createClearRegistrationsCliCmd(fileConfig: FileConfig) {
692689
const options: ProgramOption = cmd.optsWithGlobals();
693690

694691
const ip = await getDeviceIp(options, fileConfig);
695-
if (ip !== undefined) {
696-
HPApi.setDeviceIP(ip);
697-
}
692+
HPApi.setDeviceIP(ip);
698693

699694
const isDebug = getIsDebug(options, fileConfig);
700695
HPApi.setDebug(isDebug);

src/scanJobHandlers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ async function handleScanProcessingState(
8181
job.binaryURL !== null &&
8282
job.currentPageNumber !== null
8383
) {
84-
8584
const destinationFilePath = await PathHelper.getFileForPage(
8685
folder,
8786
scanCount,

0 commit comments

Comments
 (0)