Skip to content

Commit a8f1c1f

Browse files
committed
node-wifiscanner2 fix
1 parent 1d40b46 commit a8f1c1f

5 files changed

Lines changed: 140 additions & 7 deletions

File tree

lib/wifi-control.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/wifiscanner.js

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"sync-exec": "^0.6.2"
1010
},
1111
"scripts": {
12+
"build": "coffee -c -o lib/ src/",
1213
"test": "echo \"Error: no test specified\" && exit 1"
1314
},
1415
"repository": {
@@ -24,12 +25,17 @@
2425
"ssid"
2526
],
2627
"author": "Mark Solters <msolters@gmail.com>",
27-
"contributors": [{
28-
"name": "Aaronov",
29-
"email": ""
30-
}],
28+
"contributors": [
29+
{
30+
"name": "Aaronov",
31+
"email": ""
32+
}
33+
],
3134
"bugs": {
3235
"url": "https://github.com/msolters/wifi-control-node/issues"
3336
},
34-
"homepage": "https://github.com/msolters/wifi-control-node"
37+
"homepage": "https://github.com/msolters/wifi-control-node",
38+
"devDependencies": {
39+
"coffeescript": "1.12.4"
40+
}
3541
}

src/wifi-control.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# (1) Load NPM Dependencies.
33
#
44
# node-wifiscanner2 is a great NPM package for scanning WiFi APs (for Windows & Mac -- it REQUIRES sudo on Linux).
5-
WiFiScanner = require 'node-wifiscanner2'
5+
WiFiScanner = require './wifiscanner'
66
# To execute commands in the host machine, we'll use sync-exec.
77
# Note: In nodejs >= v0.12 this will default to child_process.execSync.
88
execSyncToBuffer = require 'sync-exec'

src/wifiscanner.coffee

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
fs = require('fs')
2+
osLocale = require('os-locale')
3+
airport = require('node-wifiscanner2/lib/airport')
4+
iwlist = require('node-wifiscanner2/lib/iwlist')
5+
nmcli = require('node-wifiscanner2/lib/nmcli')
6+
netsh = require('node-wifiscanner2/lib/netsh')
7+
enLocale = require('node-wifiscanner2/locales/en.json')
8+
deLocale = require('node-wifiscanner2/locales/de.json')
9+
terms = undefined
10+
fullLocale = osLocale.sync(spawn: true) or 'en_US'
11+
12+
###* quick-fix:start *###
13+
14+
setLocale = (locale) ->
15+
shortLocale = locale.split('_')[0]
16+
if shortLocale.indexOf('de') >= 0
17+
terms = deLocale
18+
else
19+
terms = enLocale
20+
return
21+
22+
###* quick-fix:end *###
23+
24+
scan = (callback) ->
25+
fs.exists airport.utility, (exists) ->
26+
if exists
27+
airport.scan terms.airport, callback
28+
return
29+
fs.exists nmcli.utility, (exists) ->
30+
if exists
31+
nmcli.scan terms.nmcli, callback
32+
return
33+
fs.exists iwlist.utility, (exists) ->
34+
if exists
35+
iwlist.scan terms.iwlist, callback
36+
return
37+
fs.exists netsh.utility, (exists) ->
38+
if exists
39+
netsh.scan terms.netsh, callback
40+
return
41+
callback 'No scanning utility found', null
42+
return
43+
return
44+
return
45+
return
46+
return
47+
48+
setLocale fullLocale
49+
exports.scan = scan
50+
exports.setLocale = setLocale

0 commit comments

Comments
 (0)