diff --git a/docs/index.html b/docs/index.html
index d6f759e..b9cce41 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -212,7 +212,7 @@
Downloads last month
diff --git a/lib/util.js b/lib/util.js
index 223c0e4..a5aa90c 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -375,7 +375,7 @@ function getWmic() {
} else {
wmicPath = 'wmic';
}
- } catch (e) {
+ } catch {
wmicPath = 'wmic';
}
}
@@ -471,7 +471,7 @@ function powerShellRelease() {
_psChild.stdin.end();
_psPersistent = false;
}
- } catch (e) {
+ } catch {
if (_psChild) {
_psChild.kill();
}
@@ -480,11 +480,6 @@ function powerShellRelease() {
}
function powerShell(cmd) {
- /// const pattern = [
- /// '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
- /// '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
- /// ].join('|');
-
if (_psPersistent) {
const id = Math.random().toString(36).substring(2, 12);
return new Promise((resolve) => {
@@ -502,7 +497,7 @@ function powerShell(cmd) {
if (_psChild && _psChild.pid) {
_psChild.stdin.write(_psToUTF8 + 'echo ' + _psCmdStart + id + _psIdSeperator + '; ' + os.EOL + cmd + os.EOL + 'echo ' + _psCmdSeperator + os.EOL);
}
- } catch (e) {
+ } catch {
resolve('');
}
});
@@ -513,7 +508,12 @@ function powerShell(cmd) {
return new Promise((resolve) => {
process.nextTick(() => {
try {
- const child = spawn(_powerShell, ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-ExecutionPolicy', 'Unrestricted', '-Command', cmd], {
+ const osVersion = os.release().split('.').map(Number);
+ const spanOptions =
+ osVersion[0] < 10
+ ? ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-']
+ : ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-ExecutionPolicy', 'Unrestricted', '-Command', cmd];
+ const child = spawn(_powerShell, spanOptions, {
stdio: 'pipe',
windowsHide: true,
maxBuffer: 1024 * 102400,
@@ -543,18 +543,20 @@ function powerShell(cmd) {
child.kill();
resolve(result);
});
- // try {
- // child.stdin.write(_psToUTF8 + cmd + os.EOL);
- // child.stdin.write('exit' + os.EOL);
- // child.stdin.end();
- // } catch (e) {
- // child.kill();
- // resolve(result);
- // }
+ if (osVersion[0] < 10) {
+ try {
+ child.stdin.write(_psToUTF8 + cmd + os.EOL);
+ child.stdin.write('exit' + os.EOL);
+ child.stdin.end();
+ } catch {
+ child.kill();
+ resolve(result);
+ }
+ }
} else {
resolve(result);
}
- } catch (e) {
+ } catch {
resolve(result);
}
});
@@ -1124,7 +1126,7 @@ function getRpiGpu(cpuinfo) {
try {
cpuinfo = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).toString().split('\n');
_rpi_cpuinfo = cpuinfo;
- } catch (e) {
+ } catch {
return false;
}
}
@@ -1140,22 +1142,23 @@ function getRpiGpu(cpuinfo) {
}
function promiseAll(promises) {
- const resolvingPromises = promises.map(function (promise) {
- return new Promise(function (resolve) {
- let payload = new Array(2);
- promise
- .then(function (result) {
- payload[0] = result;
- })
- .catch(function (error) {
- payload[1] = error;
- })
- .then(function () {
- // The wrapped Promise returns an array: 0 = result, 1 = error ... we resolve all
- resolve(payload);
- });
- });
- });
+ const resolvingPromises = promises.map(
+ (promise) =>
+ new Promise((resolve) => {
+ const payload = new Array(2);
+ promise
+ .then((result) => {
+ payload[0] = result;
+ })
+ .catch((error) => {
+ payload[1] = error;
+ })
+ .then(() => {
+ // The wrapped Promise returns an array: 0 = result, 1 = error ... we resolve all
+ resolve(payload);
+ });
+ })
+ );
const errors = [];
const results = [];