`dree.scan('~')` returns null instead of scanning the home folder
AlexanderZeilmann opened this issue · 2 comments
AlexanderZeilmann commented
dree.scan('~')
always returns null
instead of scanning the home folder.
This seems to be because statSync('~')
here (https://github.com/euberdeveloper/dree/blob/main/source/lib/index.ts#L414-L420) throws an error
Uncaught Error: ENOENT: no such file or directory, stat '~'
at statSync (node:fs:1690:3) {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '~'
}
I am currently using dree.scan(require('os').homedir())
as a workaround, so it is not a big problem for me, but you might want to include something like the following code in dree as a convenience.
if (path.startsWith('~')) {
path = require('os').homedir() + path.slice(1)
}
euberdeveloper commented
Added on version 4.7.0 (#37 )
Note that you have to activate this behaviour by adding the option "homeShortcut: true" (more info in the docs)
AlexanderZeilmann commented
That was quick! Thank you 🎉