Skip to content

Commit

Permalink
bind for required plateform
Browse files Browse the repository at this point in the history
  • Loading branch information
Susheer committed Nov 11, 2024
1 parent fded61c commit 2cb73ba
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/binding.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
const addon = require('./electron_printer.node');
const path = require('path');
const os = require('os');
let addon = {}, binary_path;
switch (os.platform()) {
case 'win32':
if (os.arch() === 'ia32') {
binary_path = path.join(__dirname, 'electron_printer_win32_ia32.node');
} else if (os.arch() === 'x64') {
binary_path = path.join(__dirname, 'electron_printer_win32_x64.node');
}
addon = require(binary_path);
break;
case 'darwin':
binary_path = path.join(__dirname, 'electron_printer.node');
addon = require(binary_path);
break;
case 'linux':
if (os.arch() === 'ia32') {
addon = path.join(__dirname, 'electron_printer.node');
} else if (os.arch() === 'x64') {
addon = path.join(__dirname, 'electron_printer.node');
}
break;
default:
binary_path = path.join(__dirname, 'electron_printer.node');
addon = require(binary_path);
}

module.exports.sayMyName = addon.SayMyName
module.exports.getPrinters = addon.getPrinters
module.exports.printDirect = printDirect
Expand Down

0 comments on commit 2cb73ba

Please sign in to comment.