refactoring (windows codepage issues) wifi.js
This commit is contained in:
parent
0a25f008ce
commit
836bd855f1
23
lib/wifi.js
23
lib/wifi.js
@ -414,16 +414,15 @@ function wifiNetworks(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
} else if (_windows) {
|
||||
let cmd = 'chcp 65001 && netsh wlan show networks mode=Bssid';
|
||||
exec(cmd, util.execOptsWin, function (error, stdout) {
|
||||
|
||||
let cmd = 'netsh wlan show networks mode=Bssid';
|
||||
util.powerShell(cmd).then((stdout, error) => {
|
||||
const ssidParts = stdout.toString('utf8').split(os.EOL + os.EOL + 'SSID ');
|
||||
ssidParts.shift();
|
||||
|
||||
ssidParts.forEach(ssidPart => {
|
||||
const ssidLines = ssidPart.split(os.EOL);
|
||||
if (ssidLines && ssidLines.length >= 8 && ssidLines[0].indexOf(':') >= 0) {
|
||||
const bssidsParts = ssidPart.split('BSSID ');
|
||||
const bssidsParts = ssidPart.split(' BSSID');
|
||||
bssidsParts.shift();
|
||||
|
||||
bssidsParts.forEach((bssidPart) => {
|
||||
@ -571,8 +570,12 @@ function wifiConnections(callback) {
|
||||
});
|
||||
} else if (_windows) {
|
||||
let cmd = 'netsh wlan show interfaces';
|
||||
exec(cmd, util.execOptsWin, function (error, stdout) {
|
||||
const parts = stdout.toString().split(': \r\n\r\n');
|
||||
util.powerShell(cmd).then(function (stdout, error) {
|
||||
const allLines = stdout.toString().split('\r\n')
|
||||
for (let i = 0; i < allLines.length; i++) {
|
||||
allLines[i] = allLines[i].trim()
|
||||
};
|
||||
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
||||
parts.shift();
|
||||
parts.forEach(part => {
|
||||
const lines = part.split('\r\n');
|
||||
@ -667,8 +670,12 @@ function wifiInterfaces(callback) {
|
||||
});
|
||||
} else if (_windows) {
|
||||
let cmd = 'netsh wlan show interfaces';
|
||||
exec(cmd, util.execOptsWin, function (error, stdout) {
|
||||
const parts = stdout.toString().split(': \r\n\r\n');
|
||||
util.powerShell(cmd).then(function (stdout, error) {
|
||||
const allLines = stdout.toString().split('\r\n')
|
||||
for (let i = 0; i < allLines.length; i++) {
|
||||
allLines[i] = allLines[i].trim()
|
||||
};
|
||||
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
||||
parts.shift();
|
||||
parts.forEach(part => {
|
||||
const lines = part.split('\r\n');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user