reveal-sdk-node
Version:
RevealBI Node.js SDK
48 lines (46 loc) • 1.65 kB
JavaScript
const os = require('os');
const path = require('path');
const ARCH_WIN_X64 = "win-x64";
const PLATFORM_OSX = "osx";
const platformArchs = [ARCH_WIN_X64, "linux-x64", "osx-x64","linux-arm64","osx-arm64"];
const prgName = "RevealEnginePrg";
let platform = os.platform();
if (platform == "win32") {
platform = "win"; // for .net it is 'win', not 'win32'.
} else if (platform == "darwin") {
platform = PLATFORM_OSX;
}
let arch = os.arch();
if (platform === PLATFORM_OSX) {
arch = "x64"; // Rosetta!
}
const platformArch = platform + "-" + arch;
function getPlatformArchRelativePath(platformArch) {
return "native" + path.sep + platformArch;
}
function extension(arch) {
return arch == ARCH_WIN_X64 ? ".exe" : "";
}
function getBinaryName(platformArch) {
return prgName + extension(platformArch);
}
function getBinaryRelativePath(platformArch) {
return getPlatformArchRelativePath(platformArch) + path.sep + getBinaryName(platformArch);
}
const binaryName = getBinaryName(platformArch);
const platformArchRelativePath = getPlatformArchRelativePath(platformArch);
const binaryRelativePath = getBinaryRelativePath(platformArch);
module.exports = {
arch: arch,
platform: platform,
platformArch: platformArch,
binaryName: binaryName,
platformArchRelativePath: platformArchRelativePath,
binaryRelativePath: binaryRelativePath,
platformArchs: platformArchs,
prgName: prgName,
extension: extension,
getPlatformArchRelativePath: getPlatformArchRelativePath,
getBinaryName: getBinaryName,
getBinaryRelativePath: getBinaryRelativePath
}