mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Check parent directories for Cakefiles. Closes #1686
This commit is contained in:
@@ -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 '.'
|
||||
|
||||
Reference in New Issue
Block a user