diff --git a/documentation/coffee/block_comment.coffee b/documentation/coffee/block_comment.coffee index dba86b6c..47d50f3c 100644 --- a/documentation/coffee/block_comment.coffee +++ b/documentation/coffee/block_comment.coffee @@ -1,5 +1,5 @@ ### -CoffeeScript Compiler v1.1.2 +CoffeeScript Compiler v1.1.3 Released under the MIT License ### diff --git a/documentation/docs/cake.html b/documentation/docs/cake.html index 3824c8d9..9490119f 100644 --- a/documentation/docs/cake.html +++ b/documentation/docs/cake.html @@ -21,15 +21,16 @@ as the first argument to the action.
Run cake
. Executes all of the tasks you pass, in order. Note that Node's
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 = ->
- path.exists 'Cakefile', (exists) ->
- throw new Error("Cakefile not found in #{process.cwd()}") unless exists
- args = process.argv.slice 2
- CoffeeScript.run fs.readFileSync('Cakefile').toString(), filename: 'Cakefile'
- oparse = new optparse.OptionParser switches
- return printTasks() unless args.length
- options = oparse.parse(args)
- invoke arg for arg in options.arguments
Display the list of Cake tasks in a format similar to rake -T
printTasks = ->
+If no tasks are passed, print the help screen. Keep a reference to the
+original directory name, when running Cake tasks from subdirectories.
exports.run = ->
+ global.__originalDirname = fs.realpathSync '.'
+ process.chdir cakefileDirectory __originalDirname
+ args = process.argv.slice 2
+ CoffeeScript.run fs.readFileSync('Cakefile').toString(), filename: 'Cakefile'
+ oparse = new optparse.OptionParser switches
+ return printTasks() unless args.length
+ options = oparse.parse(args)
+ invoke arg for arg in options.arguments
Display the list of Cake tasks in a format similar to rake -T
printTasks = ->
console.log ''
for name, task of tasks
spaces = 20 - name.length
@@ -38,6 +39,11 @@ If no tasks are passed, print the help screen.
Print an error and exit when attempting to call an undefined task.
missingTask = (task) ->
console.log "No such task: \"#{task}\""
- process.exit 1
+ process.exit 1
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()}"