Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

added coffee support

Fredrik Lindin8732fc63dc54
diff --git a/bin/mocha b/bin/mocha
index e4730ead..75b97344 100755
--- a/bin/mocha
+++ b/bin/mocha
@@ -104,11 +104,19 @@ if (program.timeout) suite.timeout(program.timeout);
var files = program.args;
-// default files to test/*.js
+/**
+ * Defaults matching path to test/*.js and adjusts
+ * to check for *.coffee as well if CS is available
+ */
if (!files.length) {
+ var fileMatcher = /\.js$/;
files = fs.readdirSync('test').filter(function(path){
- return path.match(/\.js$/);
+ try {
+ require('coffee-script');
+ fileMatcher = /\.(js|coffee)$/;
+ } catch (e) {}
+ return path.match(fileMatcher);
}).map(function(path){
return join('test', path);
});
@@ -176,4 +184,4 @@ function notify(msg, options) {
if (options.name) args.push('--name', options.name);
if (options.title) args.push(options.title);
exec(args.join(' '), fn);
-}
\ No newline at end of file
+}