-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiohookinstall.js
48 lines (37 loc) · 1.22 KB
/
iohookinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// const path = require('path');
// const runtime = process.versions['electron'] ? 'electron' : 'node';
// const essential = runtime + '-v' + process.versions.modules + '-' + process.platform + '-' + process.arch;
// const modulePath = path.join(__dirname, 'builds', essential, 'build', 'Release', 'iohook.node');
// console.info('The path is:', modulePath);
var which = require('which')
var AutoLaunch = require('auto-launch');
const trackerBinPath = which.sync('localTracker', {nothrow: true})
if (trackerBinPath == null) {
return console.error("Cant find localTracker, need to install it first")
}
const nodeBinPath = which.sync('node', {nothrow: true})
if (nodeBinPath == null) {
return console.error("Cant find node, need to install it first")
}
console.log("trackerBinPath",trackerBinPath)
var autoLauncher = new AutoLaunch({
name: 'LocalTracker',
path: nodeBinPath,
extraArgs: trackerBinPath,
mac: {
useLaunchAgent: true
}
});
autoLauncher.enable();
//autoLauncher.disable();
autoLauncher.isEnabled()
.then(function(isEnabled){
if(isEnabled){
return;
}
autoLauncher.enable();
})
.catch(function(err){
// handle error
console.error("autolauncher error",err)
});