mihneadb / node-directory-tree

Convert a directory tree to a JS object.
MIT License
523 stars 106 forks source link

fixed "EPERM" error for Windows user. #59

Closed Fchen48 closed 5 years ago

Fchen48 commented 5 years ago

If you will scan on Windows you will receive the following error:

Error: EPERM: operation not permitted, scandir '\documents and settings'

This pr will fix this in a simple way.

npm test doesn't work for me, it will fail directly after fork, I think the size will calculate differently on Windows. Ok, CI passed.

TomoyukiAota commented 5 years ago

I encountered EPERM when accessing C:\Users\MyUserName\Documents\My Music. My Music, My Pictures, My Videos in Documents causes EPERM error. The reason is described here.

Currently, if any of files/directoies emit EPERM, this npm module just throws an error and fails to return the directory tree object. With this PR, it ignores such files/directories, which is a more useful behavior. (Also, if it can let users handle such errors, that's great, but the minimum viable behavior is just to ignore instead of to throw an error and fail to return the directory tree object.)

@mihneadb Is this PR going to be merged?

Fchen48 commented 5 years ago

@mihneadb Any problems with the PR?

mihneadb commented 5 years ago

@Fchen48 sorry about the lag. Merging & releasing now. Thanks!