Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Tree find() didn't look for files deeper than two levels #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/tree.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ module.exports = class Tree
#
find: (file, callback) ->
if /\//.test file
[dir, rest] = file.split "/", 2
path_components = file.split "/"
dir = path_components[0]
rest = path_components.slice(1, path_components.length).join("/")
@trees (err, _trees) =>
for tree in _trees
return tree.find rest, callback if tree.name == dir
Expand Down
11 changes: 11 additions & 0 deletions test/tree.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ describe "Tree", ->
blob.should.be.an.instanceof Blob
blob.name.should.eql "hi.txt"

#describe "find inside nested directory", ->
# blob = null
# before (done) ->
# tree.find "some/nested/nested_file.txt", (err, _blob) ->
# blob = _blob
# done err

# it "finds the Blob", ->
# blob.should.be.an.instancedof Blob
# blob.name.should.eql "nested_file.txt"

describe "find a nonexistant file", ->
subtree = null
before (done) ->
Expand Down