Skip to content

Commit

Permalink
add coffee-script support
Browse files Browse the repository at this point in the history
  • Loading branch information
kaichen committed Jan 21, 2011
1 parent b3ced68 commit 4d0584d
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions bin/spark
Expand Up @@ -38,6 +38,22 @@ var comment;

var workers;

/**
* Coffee script support
*/

var fileExtname

try {
var coffee = require('coffee-script');
require.registerExtension('.coffee', function (content) {
return coffee.compile(content);
});
fileExtname = /\.(js|coffee)$/;
} catch (_) {
fileExtname = /\.js$/;
}

/**
* Verbose output.
*/
Expand Down Expand Up @@ -157,7 +173,7 @@ function mkdirs(path, mode) {
*/

function modulePath(path){
return path.replace(/\.js$/, '');
return path.replace(fileExtname, '');
}

/**
Expand Down Expand Up @@ -253,8 +269,14 @@ function getAppPath() {
} else if (exists(path + 'server.js')) {
log('detected server.js');
path += 'server';
} else if (exists(path + 'app.coffee')) {
log('detected app.coffee');
path += 'app';
} else if (exists(path + 'server.coffee')) {
log('detected server.coffee');
path += 'server';
} else {
abort('app not found, pass a module path, or create {app,server}.js');
abort('app not found, pass a module path, or create {app,server}.{js,coffee}');
}
}

Expand Down

0 comments on commit 4d0584d

Please sign in to comment.