Skip to content

Instantly share code, notes, and snippets.

@bitmage
Created January 9, 2012 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitmage/1581070 to your computer and use it in GitHub Desktop.
Save bitmage/1581070 to your computer and use it in GitHub Desktop.
functions for finding rzr project root
exports.findParent = findParent = (dir, pred) ->
return null if dir == '/'
if pred(dir)
return dir
else
upDir = normalize(dir + '/..')
return findParent(upDir, pred)
end
rzrRootTest = (dir) ->
'domain' in readdirSync(dir)
exports.projectRoot = projectRoot = () ->
root ?= findParent process.cwd(), rzrRootTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment