From c24ffbcde694b8b53b6bedda387c20d37218f34f Mon Sep 17 00:00:00 2001 From: Richter Daniel Date: Wed, 24 Jul 2019 09:30:22 +0200 Subject: [PATCH] added Fallback Solution for Electron and VSCode --- binding.gyp | 10 +++- lib/wrapper/sapnwrfc-client.js | 21 +++++++- lib/wrapper/sapnwrfc-client.js.map | 2 +- package-lock.json | 81 +++++++++++------------------- package.json | 3 +- src/ts/wrapper/sapnwrfc-client.ts | 22 ++++++-- 6 files changed, 79 insertions(+), 60 deletions(-) diff --git a/binding.gyp b/binding.gyp index f378799..9b68435 100644 --- a/binding.gyp +++ b/binding.gyp @@ -3,8 +3,12 @@ "sapnwrfcsdk_path_linux": "$(SAPNWRFC_HOME)", "sapnwrfcsdk_path_windows": " import * as Promise from 'bluebird'; +import * as fs from 'fs'; const binary = require('node-pre-gyp'); +const validation = require('node-pre-gyp/lib/util/versioning'); const path = require('path'); -const binding_path = binary.find(path.resolve(path.join(__dirname, '../../package.json'))); - +const packageJsonPath = path.resolve(path.join(__dirname, '../../package.json')); +let binding_path = binary.find(packageJsonPath); let binding: RfcClientBinding; try { binding = require(binding_path); @@ -13,7 +15,21 @@ try { ex.message += ['win32', 'linux', 'darwin'].indexOf(process.platform) !== -1 ? '\n\n The SAP NW RFC SDK could not be loaded, check the installation: http://sap.github.io/node-rfc/install.html#sap-nw-rfc-sdk-installation' : `\n\nPlatform not supported: ${process.platform}`; - throw ex; + ex.message += "\n\nSearchPath: " + binding_path; + const packageJson = require(packageJsonPath); + packageJson.binary.module_path = packageJson.binary.module_path_wout_abi; + binding_path = validation.evaluate(packageJson, { module_root: path.dirname(packageJsonPath)}, 'v69').module; + try { + binding = require(binding_path); + } catch (ex2) { + if (ex2.message.indexOf('sapnwrfc.node') !== -1) + ex2.message += ['win32', 'linux', 'darwin'].indexOf(process.platform) !== -1 ? + '\n\n The SAP NW RFC SDK could not be loaded, check the installation: http://sap.github.io/node-rfc/install.html#sap-nw-rfc-sdk-installation' : + `\n\nPlatform not supported: ${process.platform}`; + ex2.message += "\n\nSearchPath: " + binding_path; + ex2.message += ex.message; + throw ex2; + } } interface RfcConnectionInfo { host: string;