Issue #1687. Keeping a reference to __originalDirname in Cake tasks, after Node's __dirname

This commit is contained in:
Jeremy Ashkenas 2011-09-11 23:41:50 -04:00
parent 85342f1e31
commit c5dbb1c933
2 changed files with 6 additions and 4 deletions

View File

@ -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'

View File

@ -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