Skip to content
Browse files

Add support for Streamlined Cakefiles!

In order to not have to manually reimplement much or all of Cake, achieving
Streamlining via the in-file require('streamline/module') directive.

This change is thus just to recognize Cakefiles as CoffeeScript and output the
generated tmp file with a .coffee extension, which makes things work.
  • Loading branch information...
1 parent e6ce0cb commit 50baa98c3ae622d63f1edabd27a6a9a0e96377ae @aseemk committed May 27, 2012
Showing with 8 additions and 1 deletion.
  1. +6 −0 examples/misc/Cakefile
  2. +2 −1 lib/compiler/register.js
View
6 examples/misc/Cakefile
@@ -0,0 +1,6 @@
+return if not require('streamline/module')(module)
+
+task 'greet', (options, _) ->
+ console.log 'Hello...'
+ setTimeout _, 1000
+ console.log '...world!'
View
3 lib/compiler/register.js
@@ -62,7 +62,8 @@ exports.trackModule = function(m, options) {
m.filename = m.filename.replace(/\\/g, '/');
var tmp = m.filename.substring(0, m.filename.lastIndexOf('/'));
- tmp += '/tmp--' + Math.round(Math.random() * 1e9) + path.extname(m.filename);
+ var ext = (path.basename(m.filename) === 'Cakefile') ? '.coffee' : path.extname(m.filename);
+ tmp += '/tmp--' + Math.round(Math.random() * 1e9) + ext;
//console.error("WARNING: streamline not registered, re-loading module " + m.filename + " as " + tmp);
exports.register({});
fs.writeFileSync(tmp, fs.readFileSync(m.filename, "utf8"), "utf8");

0 comments on commit 50baa98

Please sign in to comment.
Something went wrong with that request. Please try again.