fix: faulty hidden files detection on Windows

Massimo Melina committed Jun 19, 2024 at 09:38 UTC cfdeab91432e636d9c124e2d1fb96c2f64ce2c6f
1 file changed +2 -2
src/util-files.ts
+2 -2
@@ -98,8 +98,8 @@ export async function* dirStream(path: string, { depth=0, onlyFiles=false, onlyF
98 const winPath = path.replace(/\//g, '\\')
99 const out = await runCmd('dir', ['/ah', '/b', depth ? '/s' : '/c', winPath]) // cannot pass '', so we pass /c as a noop parameter
100 .catch(()=>'') // error in case of no matching file
101 - return out.split('\r\n').slice(0,-1).map(x =>
102 - !depth ? x : x.slice(winPath.length + 1).replace(/\\/g, '/'))
101 + return out.split('\n').map(x =>
102 + x.slice(!depth ? 0 : winPath.length + 1).trim().replace(/\\/g, '/'));
103 }
104 }
105