Permalink
Browse files

Merge pull request #123 from jinze/jakelib-coffee

CoffeeScript support for .jake.coffee files in jakelib
  • Loading branch information...
2 parents 90b6168 + 5f9ff69 commit b79973735169aafb9616792660bff959b5e02c7f @mde mde committed May 14, 2012
Showing with 14 additions and 7 deletions.
  1. +14 −7 lib/loader.js
View
@@ -24,7 +24,7 @@ var path = require('path')
Loader = function () {
- var JAKEFILE_PAT = /\.jake$/;
+ var JAKEFILE_PAT = /\.jake(\.js|\.coffee)?$/;
var _loadJakefile = function (file) {
var jakefile = file ?
@@ -56,12 +56,7 @@ Loader = function () {
isCoffee = path.existsSync(jakefile + '.coffee');
if (isCoffee) {
- try {
- CoffeeScript = require('coffee-script');
- }
- catch (e) {
- fail('CoffeeScript is missing! Try `npm install coffee-script`');
- }
+ CoffeeScript = _requireCoffee();
}
require(fileUtils.absolutize(jakefile));
}
@@ -74,10 +69,22 @@ Loader = function () {
dirlist = fs.readdirSync(dirname);
dirlist.forEach(function (filePath) {
if (JAKEFILE_PAT.test(filePath)) {
+ if (/\.coffee$/.test(filePath)) {
+ CoffeeScript = _requireCoffee();
+ }
require(path.join(dirname, filePath));
}
});
}
+ }
+
+ , _requireCoffee = function() {
+ try {
+ return require('coffee-script');
+ }
+ catch (e) {
+ fail('CoffeeScript is missing! Try `npm install coffee-script`');
+ }
};
this.load = function (opts) {

0 comments on commit b799737

Please sign in to comment.