遍历当前文件夹下的文件并进行回调操作

@param  {string}   curDir 当前的目录
@param  {Function} cb callback function
function traverseFilesAndCb(curDir, cb) {
    let fileDirs = [curDir];
    while (fileDirs.length) {
        let currDir = fileDirs.pop();
        let files = fs.readdirSync(currDir);
        for (let i = 0, len = files.length; i < len; i++) {
            let fileName = files[i];

            if (/^\./.test(fileName)) {
                continue;
            }

            let fullPath = path.resolve(currDir, fileName);
            let stat = getFileState(fullPath);
            if (!stat) {
                continue;
            }

            let isDir = stat.isDirectory();
            if (isDir) {
                fileDirs.push(fullPath);
                continue;
            }

            if (typeof cb === 'function') {
                cb(fullPath);
            }
        }
    }
}