test/_spec.js
/*
 * Walk directory and find all .js files. Then check if a corresponding
 * ./test/*_spec.js file exists.
 */
Walk directory and find all .js files. Then check if a corresponding
./test_spec.js file exists.
Walk directory and find all . js files . Then check if a corresponding . / test_spec . js file exists .
function walkDirectory(directory, done) {
    fs.readdir(directory, function(err, list) {
        if (err) {
            return done(err);
        }
        var i = 0;
        function nextEntry() {
            var file = list[i++];
            if (!file) {
                return;
            }
            file = directory + '/' + file;
            fs.stat(file, function(err, stat) {
                if (stat && stat.isDirectory()) {
                    walkDirectory(file, function(err, res) {
                        nextEntry();
                    });
                } else {
                    if (/\.js$/.test(file)) {
                        file = file.replace("/../", "/");
                        file = file.replace(".js", "_spec.js");
                        fs.exists(file, function(exists) {
                            try {
                                exists.should.equal(true, file + " does not exist");   
                            } catch (err) {
                                done(err);
                            }
                        });
                    }
                    nextEntry();
                }
            });
        }
        nextEntry();
    });
}
function walkDirectory ( directory , done ) { fs . readdir ( directory , function ( err , list ) { if ( err ) { return done ( err ) ; } var i = 0 ; function nextEntry ( ) { var file = list [ i ++ ] ; if ( ! file ) { return ; } file = directory + '/' + file ; fs . stat ( file , function ( err , stat ) { if ( stat && stat . isDirectory ( ) ) { walkDirectory ( file , function ( err , res ) { nextEntry ( ) ; } ) ; } else { if ( / \.js$ / . test ( file ) ) { file = file . replace ( "/../" , "/" ) ; file = file . replace ( ".js" , "_spec.js" ) ; fs . exists ( file , function ( exists ) { try { exists . should . equal ( true , file + " does not exist" ) ; } catch ( err ) { done ( err ) ; } } ) ; } nextEntry ( ) ; } } ) ; } nextEntry ( ) ; } ) ; }
Walk directory and find all .js files.
Walk directory and find all . js files .