node-directory-tree icon indicating copy to clipboard operation
node-directory-tree copied to clipboard

Depth Option

Open fweinrich opened this issue 8 years ago • 7 comments

Simple depth option

fweinrich avatar Nov 22 '17 10:11 fweinrich

fixed the spacing

fweinrich avatar Dec 02 '17 21:12 fweinrich

added the spaces, fixed the recursive function and removed the extra if statement

fweinrich avatar Dec 05 '17 18:12 fweinrich

Any updates on this PR? I'm interested by this feature. 👍

kwent avatar Dec 30 '17 13:12 kwent

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

kwent avatar Jan 01 '18 20:01 kwent

You are right @kwent, fixed that.

fweinrich avatar Jan 02 '18 06:01 fweinrich

@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.depth stuff 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!

mihneadb avatar Jan 10 '18 17:01 mihneadb

  • reindented the file
  • children is now [] if the directory is not scanned anymore
  • moved the check to the top and removed the depth var

fweinrich avatar Jan 13 '18 17:01 fweinrich