diff --git a/lib/coffee-script/cake.js b/lib/coffee-script/cake.js index 353563bc..40984f0c 100644 --- a/lib/coffee-script/cake.js +++ b/lib/coffee-script/cake.js @@ -31,7 +31,8 @@ }); exports.run = function() { var arg, args, _i, _len, _ref, _results; - process.chdir(cakefileDirectory(fs.realpathSync('.'))); + global.__originalDirname = fs.realpathSync('.'); + process.chdir(cakefileDirectory(__originalDirname)); args = process.argv.slice(2); CoffeeScript.run(fs.readFileSync('Cakefile').toString(), { filename: 'Cakefile' diff --git a/src/cake.coffee b/src/cake.coffee index 9fc31b86..be5e71a9 100644 --- a/src/cake.coffee +++ b/src/cake.coffee @@ -39,12 +39,13 @@ helpers.extend global, missingTask name unless tasks[name] tasks[name].action options - # 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. +# 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 = -> - process.chdir cakefileDirectory fs.realpathSync '.' + 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