-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
43 lines (37 loc) · 1.13 KB
/
index.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
'use strict';
const WiFiScanner = require('./scanners/wifiscanner');
const darwinparser = require('./parsers/darwinparser');
const linuxparser = require('./parsers/linuxparser');
const windowsparser = require('./parsers/windowsparser');
const nconf = require("nconf");
function platformSelect(options) {
let platform;
if(options && options.platform) {
platform = options.platform;
delete options.platform;
}
return platform || process.platform;
}
function scanner(options) {
options = options || {}
const platform = platformSelect(options);
nconf.file(`${__dirname}/config/${platform}.json`);
let parser;
switch(platform) {
case "linux":
parser = linuxparser;
break;
case "darwin":
parser = darwinparser;
break;
case "win32":
parser = windowsparser;
break;
}
const scannerOptions = {
binaryPath: options.binaryPath || nconf.get("binaryPath"),
args: options.args || nconf.get("args"),
}
return new WiFiScanner(scannerOptions, parser);
};
module.exports = scanner;