fix: on Windows, hidden files with non-latin characters were still be listed
Massimo Melina committed
Feb 27, 2024 at 20:40 UTC
e7d144cdf0b57ee442b8ffe3b600a2500b3a88ee
1 file changed
+3
-3
src/util-os.ts
+3
-3
@@ -1,5 +1,5 @@
1
import { resolve } from 'path'
2
-import { exec, execFile, execSync } from 'child_process'
2
+import { exec, execSync } from 'child_process'
3
import { try_ } from './misc'
4
import { promisify } from 'util'
5
import { IS_WINDOWS } from './const'
@@ -27,12 +27,12 @@ export function getFreeDiskSync(path: string) {
27
}
28
29
export async function getDrives() {
30
- const { stdout } = await promisify(exec)('wmic logicaldisk get name')
30
+ const stdout = await runCmd('wmic logicaldisk get name')
31
return stdout.split('\n').slice(1).map(x => x.trim()).filter(Boolean)
32
}
33
34
// execute win32 shell commands
35
export async function runCmd(cmd: string, args: string[] = []) {
36
- const { stdout, stderr } = await promisify(execFile)('cmd', ['/c', cmd, ...args])
36
+ const { stdout, stderr } = await promisify(exec)(`@chcp 65001 >nul & cmd /c ${cmd} ${args.join(' ')}`, { encoding: 'utf-8' })
37
return stderr || stdout
38
}