Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ var loadPath = function(path, context) {
fn = files[i];
fp = path + fn;

if(!isFile(fp) || !checkFileType(fn, '.js')) {
// only load js file type
if(!isFile(fp) || !(checkFileType(fn, '.js') || checkFileType(fn, '.coffee'))) {
// only load js or coffee file type
continue;
}

Expand All @@ -82,7 +82,7 @@ var loadPath = function(path, context) {
continue;
}

var name = m.name || getFileName(fn, '.js'.length);
var name = m.name || getFileName(fn);
res[name] = m;
}

Expand Down Expand Up @@ -117,16 +117,13 @@ var isDir = function(path) {
return fs.statSync(path).isDirectory();
};

var getFileName = function(fp, suffixLength) {
var getFileName = function(fp) {
var fn = path.basename(fp);
if(fn.length > suffixLength) {
return fn.substring(0, fn.length - suffixLength);
}

return fn;
var extname = path.extname(fp);
return fn.replace(extname, '');
};

var requireUncached = function(module){
delete require.cache[require.resolve(module)]
return require(module)
}
}