@@ -5498,6 +5498,9 @@ require.register("utils.js", function(module, exports, require){
54985498
54995499var fs = require ( 'browser/fs' )
55005500 , path = require ( 'browser/path' )
5501+ , basename = path . basename
5502+ , exists = fs . existsSync || path . existsSync
5503+ , glob = require ( 'glob' )
55015504 , join = path . join
55025505 , debug = require ( 'browser/debug' ) ( 'mocha:watch' ) ;
55035506
@@ -5843,6 +5846,52 @@ exports.canonicalize = function(obj, stack) {
58435846 return canonicalizedObj ;
58445847 }
58455848
5849+ /**
5850+ * Lookup file names at the given `path`.
5851+ */
5852+ exports . lookupFiles = function lookupFiles ( path , extensions , recursive ) {
5853+ var files = [ ] ;
5854+ var re = new RegExp ( '\\.(' + extensions . join ( '|' ) + ')$' ) ;
5855+
5856+ if ( ! exists ( path ) ) {
5857+ if ( exists ( path + '.js' ) ) {
5858+ path += '.js' ;
5859+ } else {
5860+ files = glob . sync ( path ) ;
5861+ if ( ! files . length ) throw new Error ( "cannot resolve path (or pattern) '" + path + "'" ) ;
5862+ return files ;
5863+ }
5864+ }
5865+
5866+ try {
5867+ var stat = fs . statSync ( path ) ;
5868+ if ( stat . isFile ( ) ) return path ;
5869+ }
5870+ catch ( ignored ) {
5871+ return ;
5872+ }
5873+
5874+ fs . readdirSync ( path ) . forEach ( function ( file ) {
5875+ file = join ( path , file ) ;
5876+ try {
5877+ var stat = fs . statSync ( file ) ;
5878+ if ( stat . isDirectory ( ) ) {
5879+ if ( recursive ) {
5880+ files = files . concat ( lookupFiles ( file , recursive ) ) ;
5881+ }
5882+ return ;
5883+ }
5884+ }
5885+ catch ( ignored ) {
5886+ return ;
5887+ }
5888+ if ( ! stat . isFile ( ) || ! re . test ( file ) || basename ( file ) [ 0 ] === '.' ) return ;
5889+ files . push ( file ) ;
5890+ } ) ;
5891+
5892+ return files ;
5893+ }
5894+
58465895} ) ; // module: utils.js
58475896// The global object is "self" in Web Workers.
58485897var global = ( function ( ) { return this ; } ) ( ) ;
0 commit comments