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