daas-sdk
Version:
nodejs wrapper for the DaaS-IoT SDK
34 lines (29 loc) • 977 B
JavaScript
// scripts/copy-binary.js
const fs = require('fs');
const path = require('path');
// Determine the platform-specific binary path
let binaryPath;
switch (process.platform) {
case 'win32':
binaryPath = path.join(__dirname, '..', 'build', 'win32-x64', 'libdaas.node');
break;
case 'linux':
binaryPath = path.join(__dirname, '..', 'build', 'linux', 'libdaas.node');
break;
case 'darwin':
binaryPath = path.join(__dirname, '..', 'build', 'macOS', 'libdaas.node');
break;
default:
console.error(`[DaaS-IoT Node.js] error: Unsupported platform: ${process.platform}`);
process.exit(1);
}
// Destination path for the binary
const destinationPath = path.join(__dirname, '..', 'build', 'libdaas.node');
// Copy the binary
fs.copyFile(binaryPath, destinationPath, (err) => {
if (err) {
console.error('[DaaS-IoT Node.js] error while copying the addon binary:', err);
process.exit(1);
}
console.log('[DaaS-IoT Node.js] Addon binary copied successfully.');
});