Skip to content

armgit / mocha

Public Imported from GitHub
0

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

recursive option

abrkn203ae3792624
diff --git a/bin/_mocha b/bin/_mocha
index aea22709..d9458de1 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -204,18 +204,17 @@ var files = program.args;
// default files to test/*.{js,coffee}
-if (!files.length) {
- var recursive = ~process.argv.indexOf('--recursive')
- , dir = function(p) {
- fs.readdirSync(p)
- .forEach(function(child) {
+function dir(p) {
+ fs.readdirSync(p).forEach(function(child) {
child = path.join(p, child);
var stat = fs.statSync(child);
- if (stat.isDirectory()) return recursive ? dir(child) : null
- if (!stat.isFile()) return
+ if (stat.isDirectory()) return program.recursive ? dir(child) : null
+ if (!stat.isFile() || !re.test(child)) return
files.push(child);
- });
- }
+ });
+}
+
+if (!files.length) {
dir(path.join(cwd, 'test'))
}