Skip to content

Commit

Permalink
code cleanup, refresh rate (win)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Nov 20, 2022
1 parent 24cfe46 commit c5647a6
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/cpu.js
Expand Up @@ -525,11 +525,11 @@ function getSocketTypesByName(str) {
let result = '';
for (const key in socketTypesByName) {
const names = socketTypesByName[key].split(' ');
for (let i = 0; i < names.length; i++) {
if (str.indexOf(names[i]) >= 0) {
names.forEach(element => {
if (str.indexOf(element) >= 0) {
result = key;
}
}
});
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/docker.js
Expand Up @@ -458,7 +458,7 @@ function dockerContainerStats(containerIDs, callback) {
containerIDsSanitized = '';
const s = (util.isPrototypePolluted() ? '' : util.sanitizeShellString(containerIDs, true)).trim();
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
if (s[i] !== undefined) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
if (sl && sl[0] && !sl[1]) {
Expand Down
8 changes: 5 additions & 3 deletions lib/graphics.js
Expand Up @@ -864,10 +864,12 @@ function graphics(callback) {
if (_pixelDepth) {
result.displays[0].pixelDepth = _pixelDepth;
}
if (_refreshRate && !result.displays[0].currentRefreshRate) {
result.displays[0].currentRefreshRate = _refreshRate;
}
}
result.displays = result.displays.map(element => {
if (_refreshRate && !element.currentRefreshRate) {
element.currentRefreshRate = _refreshRate;
}
});

if (callback) {
callback(result);
Expand Down
2 changes: 1 addition & 1 deletion lib/internet.js
Expand Up @@ -46,7 +46,7 @@ function inetChecksite(url, callback) {
let urlSanitized = '';
const s = util.sanitizeShellString(url, true);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
if (!s[i] !== undefined) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
if (sl && sl[0] && !sl[1] && sl[0].length === 1) {
Expand Down
1 change: 0 additions & 1 deletion lib/network.js
Expand Up @@ -305,7 +305,6 @@ function getWindowsDNSsuffixes() {

return dnsSuffixes;
} catch (error) {
// console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message);
return {
primaryDNS: '',
exitCode: 0,
Expand Down
2 changes: 0 additions & 2 deletions lib/system.js
Expand Up @@ -47,15 +47,13 @@ function system(callback) {

if (_linux || _freebsd || _openbsd || _netbsd) {
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) {
// if (!error) {
let lines = stdout.toString().split('\n');
result.manufacturer = util.getValue(lines, 'manufacturer');
result.model = util.getValue(lines, 'product name');
result.version = util.getValue(lines, 'version');
result.serial = util.getValue(lines, 'serial number');
result.uuid = util.getValue(lines, 'uuid').toLowerCase();
result.sku = util.getValue(lines, 'sku number');
// }
// Non-Root values
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
Expand Down
1 change: 0 additions & 1 deletion lib/users.js
Expand Up @@ -350,7 +350,6 @@ function parseWinUsersQuery(lines) {
if (lines[i].trim()) {
const user = lines[i].substring(headerDelimiter[0] + 1, headerDelimiter[1]).trim() || '';
const tty = lines[i].substring(headerDelimiter[1] + 1, headerDelimiter[2] - 2).trim() || '';
// const dateTime = util.parseDateTime(lines[i].substring(headerDelimiter[5] + 1, 2000).trim(), culture) || '';
result.push({
user: user,
tty: tty,
Expand Down
1 change: 0 additions & 1 deletion lib/util.js
Expand Up @@ -254,7 +254,6 @@ function parseHead(head, rights) {
let result = [];
for (let i = 0; i < head.length; i++) {
if (count <= rights) {
// if (head[i] === ' ' && !space) {
if (/\s/.test(head[i]) && !space) {
to = i - 1;
result.push({
Expand Down
1 change: 0 additions & 1 deletion test/test.js
Expand Up @@ -68,7 +68,6 @@ function printTitle(title) {
}

process.stdin.on('keypress', (key, data) => {
// console.log(data);
if (data.name === 'q' && !data.shift) {
// shut down
process.exit();
Expand Down

0 comments on commit c5647a6

Please sign in to comment.