Recently, the package was criticized on Twitter as a dependency of the Discord native app for unnecessarily many invocations of Powershell. I'm quoting them here in case they are valid feedback:
it's using a library called systeminformation that calls powershell like "Get-WmiObject Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size ${drive ? '| where -property Caption -eq ' + drive : ''} | fl" instead of doing anything properly.
|
const cmd = `Get-WmiObject Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size ${drive ? '| where -property Caption -eq ' + drive : ''} | fl`; |
they're executing from DriverStore, assuming System32 AND hardcoding C:\Windows
[...]
this code scans EIGHT HUNDRED different folders to try and find an nvidia-smi binary.
|
function getNvidiaSmi() { |
|
if (_nvidiaSmiPath) { |
|
return _nvidiaSmiPath; |
|
} |
|
|
|
if (_windows) { |
|
try { |
|
const basePath = util.WINDIR + '\\System32\\DriverStore\\FileRepository'; |
|
// find all directories that have an nvidia-smi.exe file |
|
const candidateDirs = fs.readdirSync(basePath).filter(dir => { |
|
return fs.readdirSync([basePath, dir].join('/')).includes('nvidia-smi.exe'); |
|
}); |
|
// use the directory with the most recently created nvidia-smi.exe file |
|
const targetDir = candidateDirs.reduce((prevDir, currentDir) => { |
|
const previousNvidiaSmi = fs.statSync([basePath, prevDir, 'nvidia-smi.exe'].join('/')); |
|
const currentNvidiaSmi = fs.statSync([basePath, currentDir, 'nvidia-smi.exe'].join('/')); |
|
return (previousNvidiaSmi.ctimeMs > currentNvidiaSmi.ctimeMs) ? prevDir : currentDir; |
|
}); |
|
|
|
if (targetDir) { |
|
_nvidiaSmiPath = [basePath, targetDir, 'nvidia-smi.exe'].join('/'); |
|
} |
|
} catch (e) { |
|
util.noop(); |
|
} |
|
} else if (_linux) { |
|
_nvidiaSmiPath = 'nvidia-smi'; |
|
} |
|
return _nvidiaSmiPath; |
|
} |
|
const WINDIR = process.env.WINDIR || 'C:\\Windows'; |
The former appears to be already addressed in #927
They also recommend using GetACP instead of having to assume codepage 437.
|
function getCodepage() { |
|
if (_windows) { |
|
if (!codepage) { |
|
try { |
|
const stdout = execSync('chcp', execOptsWin); |
|
const lines = stdout.toString().split('\r\n'); |
|
const parts = lines[0].split(':'); |
|
codepage = parts.length > 1 ? parts[1].replace('.', '').trim() : ''; |
|
} catch (err) { |
|
codepage = '437'; |
|
} |
|
} |
|
return codepage; |
|
} |
|
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) { |
|
if (!codepage) { |
|
try { |
|
const stdout = execSync('echo $LANG', util.execOptsLinux); |
|
const lines = stdout.toString().split('\r\n'); |
|
const parts = lines[0].split('.'); |
|
codepage = parts.length > 1 ? parts[1].trim() : ''; |
|
if (!codepage) { |
|
codepage = 'UTF-8'; |
|
} |
|
} catch (err) { |
|
codepage = 'UTF-8'; |
|
} |
|
} |
|
return codepage; |
|
} |
|
} |
I am not familiar with Windows development, and some of these don't provide better alternatives, so feel free to close this issue if the claims were baseless or made without context.
Nonetheless, thanks for the work you've put into this project!
Recently, the package was criticized on Twitter as a dependency of the Discord native app for unnecessarily many invocations of Powershell. I'm quoting them here in case they are valid feedback:
systeminformation/lib/filesystem.js
Line 197 in 6ffb79a
systeminformation/lib/graphics.js
Lines 387 to 416 in 6ffb79a
systeminformation/lib/util.js
Line 38 in 6ffb79a
The former appears to be already addressed in #927
They also recommend using
GetACPinstead of having to assume codepage 437.systeminformation/lib/util.js
Lines 565 to 595 in 6ffb79a
I am not familiar with Windows development, and some of these don't provide better alternatives, so feel free to close this issue if the claims were baseless or made without context.
Nonetheless, thanks for the work you've put into this project!