index.js
function readDir(p, filter, files, prefix) {
    prefix = prefix || '';
    files = files || [];
    filter = filter || function (x) {
        return x[0] !== '.';
    };

    let dir = path.join(p, prefix);
    if (!fs.existsSync(dir)) {
        return files;
    }
    if (fs.statSync(dir).isDirectory()) {
        fs.readdirSync(dir).filter(filter).forEach(function (name) {
            readDir(p, filter, files, path.join(prefix, name));
        });
    } else {
        files.push(prefix);
    }
    return files;
}
function readDir(p, filter, files, prefix) {
    prefix = prefix || '';
    files = files || [];
    filter = filter || function (x) {
        return x[0] !== '.';
    };

    let dir = path.join(p, prefix);
    if (!fs.existsSync(dir)) {
        return files;
    }
    if (fs.statSync(dir).isDirectory()) {
        fs.readdirSync(dir).filter(filter).forEach(function (name) {
            readDir(p, filter, files, path.join(prefix, name));
        });
    } else {
        files.push(prefix);
    }
    return files;
}
function readDir ( p , filter , files , prefix ) { prefix = prefix || '' ; files = files || [ ] ; filter = filter || function ( x ) { return x [ 0 ] !== '.' ; } ; let dir = path . join ( p , prefix ) ; if ( ! fs . existsSync ( dir ) ) { return files ; } if ( fs . statSync ( dir ) . isDirectory ( ) ) { fs . readdirSync ( dir ) . filter ( filter ) . forEach ( function ( name ) { readDir ( p , filter , files , path . join ( prefix , name ) ) ; } ) ; } else { files . push ( prefix ) ; } return files ; }
Recursively read the path under the p folder.
Synchronous mode
@param {any} p
@param {any} filter
@param {any} files
@param {any} prefix
@returns {*}
Recursively read the path under the p folder . Synchronous mode