Check parent directories for Cakefiles. Closes #1686

This commit is contained in:
Filipe Fortes
2011-09-10 20:46:25 -04:00
parent 0b57b3136c
commit 6278930aef

View File

@@ -44,6 +44,7 @@ helpers.extend global,
# asynchrony may cause tasks to execute in a different order than you'd expect.
# If no tasks are passed, print the help screen.
exports.run = ->
process.chdir findCakefilePathSync(fs.realpathSync '.')
path.exists 'Cakefile', (exists) ->
throw new Error("Cakefile not found in #{process.cwd()}") unless exists
args = process.argv.slice 2
@@ -67,3 +68,11 @@ printTasks = ->
missingTask = (task) ->
console.log "No such task: \"#{task}\""
process.exit 1
# Search in current and parent directories for Cakefile
findCakefilePathSync = (curPath) ->
return curPath if path.existsSync path.join(curPath, 'Cakefile')
parent = path.normalize path.join(curPath, '..')
return findCakefilePathSync parent unless parent == curPath
# If none found, stay in current directory
return '.'