Skip to content

Commit

Permalink
Added a check for CoffeeScript files, then tries to require coffee-sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
larzconwell committed May 30, 2012
1 parent 5246dfe commit df983f6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ geddy.model.adapter = {};
geddy.utils = utils;

var App = function () {
var JSPAT = /\.js$/;
var JSPAT = /\.(js|coffee)$/;

var _getDirList = function (dirname) {
var dirList = fs.readdirSync(dirname)
Expand All @@ -58,10 +58,19 @@ var App = function () {

for (var i = 0; i < dirList.length; i++) {
fileName = dirList[i];
// Any files ending in '.js' -- e.g., 'neil_pearts.js'
// Any files ending in '.js' or '.coffee'
if (JSPAT.test(fileName)) {
// Strip the '.js', e.g., 'neil_pearts'
if(fileName.match(/\.coffee$/)) {
// fileName is a CoffeeScript file so try to require it
try {
require('coffee-script');
} catch(err) {
throw "If you'd like to use CoffeeScript with Geddy, you will need to install the module([sudo] npm install -g coffee-script)";
}
}
// Strip the extension from the file name
fileName = fileName.replace(JSPAT, '');

// Convert underscores to camelCase with
// initial cap, e.g., 'NeilPearts'
ctorName = geddy.string.camelize(fileName, true);
Expand Down

0 comments on commit df983f6

Please sign in to comment.