From 53f9bf102629c27df1ca07505111f4a1b7498531 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:53:52 -0500 Subject: [PATCH 1/3] fix: Better optional deps handling The odbc and idb are optional deps that might not be installed. When either is not available, return an error back to user instead of failing. --- lib/transports/idbTransport.js | 6 ++++++ lib/transports/odbcTransport.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lib/transports/idbTransport.js b/lib/transports/idbTransport.js index 4d0a956..1b9f61f 100644 --- a/lib/transports/idbTransport.js +++ b/lib/transports/idbTransport.js @@ -28,6 +28,11 @@ try { } function idbCall(config, xmlInput, cb) { + // idb transport is not available bail out + if (idb === null) { + cb(new Error('idb-connector module was not found, the idb transport is only usable on IBM i.'), null); + } + const { database = '*LOCAL', username = null, @@ -38,6 +43,7 @@ function idbCall(config, xmlInput, cb) { verbose = false, } = config; + let xmlOutput = ''; const sql = `call ${xslib}.iPLUGR512K(?,?,?)`; // eslint-disable-next-line new-cap diff --git a/lib/transports/odbcTransport.js b/lib/transports/odbcTransport.js index ce219a9..b68cd7b 100644 --- a/lib/transports/odbcTransport.js +++ b/lib/transports/odbcTransport.js @@ -28,6 +28,11 @@ try { } function odbcCall(config, xmlInput, done) { + // odbc transport is not available bail out + if (odbc === null) { + cb(new Error('odbc transport was not found, ensure odbc is installed properly.'), null); + } + const { host = 'localhost', username = null, From 9d13b7bc920255138415f8502429e46c20af1573 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Wed, 26 Oct 2022 17:36:45 -0500 Subject: [PATCH 2/3] fixup! fix: Better optional deps handling --- lib/transports/idbTransport.js | 3 +-- lib/transports/odbcTransport.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/transports/idbTransport.js b/lib/transports/idbTransport.js index 1b9f61f..84ae822 100644 --- a/lib/transports/idbTransport.js +++ b/lib/transports/idbTransport.js @@ -30,7 +30,7 @@ try { function idbCall(config, xmlInput, cb) { // idb transport is not available bail out if (idb === null) { - cb(new Error('idb-connector module was not found, the idb transport is only usable on IBM i.'), null); + cb(new Error('idb-connector module was not found, the idb transport is only usable on IBM i.'), null); } const { @@ -43,7 +43,6 @@ function idbCall(config, xmlInput, cb) { verbose = false, } = config; - let xmlOutput = ''; const sql = `call ${xslib}.iPLUGR512K(?,?,?)`; // eslint-disable-next-line new-cap diff --git a/lib/transports/odbcTransport.js b/lib/transports/odbcTransport.js index b68cd7b..9d257c6 100644 --- a/lib/transports/odbcTransport.js +++ b/lib/transports/odbcTransport.js @@ -28,10 +28,10 @@ try { } function odbcCall(config, xmlInput, done) { - // odbc transport is not available bail out - if (odbc === null) { - cb(new Error('odbc transport was not found, ensure odbc is installed properly.'), null); - } + // odbc transport is not available bail out + if (odbc === null) { + done(new Error('odbc transport was not found, ensure odbc is installed properly.'), null); + } const { host = 'localhost', From 12083c93641326230979ab87bc3512515a375955 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Thu, 27 Oct 2022 08:45:38 -0500 Subject: [PATCH 3/3] fixup! fixup! fix: Better optional deps handling --- lib/transports/idbTransport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transports/idbTransport.js b/lib/transports/idbTransport.js index 84ae822..e958966 100644 --- a/lib/transports/idbTransport.js +++ b/lib/transports/idbTransport.js @@ -30,7 +30,7 @@ try { function idbCall(config, xmlInput, cb) { // idb transport is not available bail out if (idb === null) { - cb(new Error('idb-connector module was not found, the idb transport is only usable on IBM i.'), null); + cb(new Error('idb-connector was not found, ensure idb-connector is installed properly (idb-connector is only available on IBM i).'), null); } const {