Recursively search through sub directories for specified directory name in node
问题 I have a directory structure like this: /git /content /repo1 /repo2 /repo3 /modules /repo4 /repo5 /tools /project /repo6 /repo7 /test /repo8 /repo9 I'd like to be able to find the path to a particular repo just by passing the repo name: searchDirForSubdir('/git', 'repo7'); // expected to return /git/tools/project/repo7 The function I have at the moment (below) returns undefined , even though the console.log call spits out the correct path. I know I'm messing up the recursion, but can't work