Skip to content

Commit

Permalink
style tweaks for #1687
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Sep 12, 2011
1 parent bd16726 commit c1f9ae8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
41 changes: 23 additions & 18 deletions lib/coffee-script/cake.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/cake.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +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 '.')
process.chdir cakefileDirectory fs.realpathSync '.'
args = process.argv.slice 2
CoffeeScript.run fs.readFileSync('Cakefile').toString(), filename: 'Cakefile'
oparse = new optparse.OptionParser switches
Expand All @@ -67,10 +67,10 @@ 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
# None found
throw new Error("Cakefile not found in #{process.cwd()}")
# When `cake` is invoked, search in the current and all parent directories
# to find the relevant Cakefile.
cakefileDirectory = (dir) ->
return dir if path.existsSync path.join dir, 'Cakefile'
parent = path.normalize path.join dir, '..'
return cakefileDirectory parent unless parent is dir
throw new Error "Cakefile not found in #{process.cwd()}"

0 comments on commit c1f9ae8

Please sign in to comment.