Depth Option
Simple depth option
fixed the spacing
added the spaces, fixed the recursive function and removed the extra if statement
Any updates on this PR? I'm interested by this feature. 👍
Tried this branch. I noticed some directory objects with a undefined type instead directory. Not sure test is covering this: https://github.com/mihneadb/node-directory-tree/pull/37/files#diff-0dab5ef74b676cf70d75f9adfe052c8fR24
You are right @kwent, fixed that.
@fweinrich sorry, I was away. A few things:
- the indentation of the file is still off
- let's just reindent everything according to the Airbnb style guide https://github.com/airbnb/javascript#whitespace
- because you check for depth later, you end up not having the
children: []part in the leaf dirs - you can totally check the base case at the beginning of the function
- it will be easier if you extract a separate function that does the recursion and has a depth param and then the public facing function just does the
if option.depthstuff and adds 1 to the starting depth if needed (you'll need it for the new base case checking)
Hope that makes sense! Thanks for doing this!
- reindented the file
- children is now [] if the directory is not scanned anymore
- moved the check to the top and removed the depth var