lib/i18n.js
function scanFolders(rootFolderPath, folders, folderFileExtensions, callback) {
        var result = [];

        console.log('Scanning:: Folders', folders);
        console.log('Scanning:: Root folder path', rootFolderPath);
        var fileExtensions = self.fileExtensions.slice();
        scanFolder();

        function scanFolder() {
            var folder = folders.shift();
            if (folder === undefined) {
//                console.log('Scanning:: Finished with result', result);
                return callback(null, result);
            }
            if(folderFileExtensions.length){
                fileExtensions = folderFileExtensions.shift();
            }
            //var path = rootFolderPath + '/' + folder;
            var path = rootFolderPath + folder;

            console.log('Scanning:: Full path to folder', path, fileExtensions);

            fs.readdir(path, function (err, list) {
                if (err) {
                    console.error("Error scanning folder: ", path);
                    return scanFolder();
                }

                var files = [];

                for (var i = 0; i < list.length; i++) {
                    if (acceptFile(path, list[i], fileExtensions)) {
                        //files.push((folder.length ? folder + '/' : folder) + list[i]);
                        files.push(path + '/' + list[i]);
                    }
                }

                result = result.concat(files);

                scanFolder();
            });
        }
    }
function scanFolders(rootFolderPath, folders, folderFileExtensions, callback) {
        var result = [];

        console.log('Scanning:: Folders', folders);
        console.log('Scanning:: Root folder path', rootFolderPath);
        var fileExtensions = self.fileExtensions.slice();
        scanFolder();

        function scanFolder() {
            var folder = folders.shift();
            if (folder === undefined) {
//                console.log('Scanning:: Finished with result', result);
                return callback(null, result);
            }
            if(folderFileExtensions.length){
                fileExtensions = folderFileExtensions.shift();
            }
            //var path = rootFolderPath + '/' + folder;
            var path = rootFolderPath + folder;

            console.log('Scanning:: Full path to folder', path, fileExtensions);

            fs.readdir(path, function (err, list) {
                if (err) {
                    console.error("Error scanning folder: ", path);
                    return scanFolder();
                }

                var files = [];

                for (var i = 0; i < list.length; i++) {
                    if (acceptFile(path, list[i], fileExtensions)) {
                        //files.push((folder.length ? folder + '/' : folder) + list[i]);
                        files.push(path + '/' + list[i]);
                    }
                }

                result = result.concat(files);

                scanFolder();
            });
        }
    }
function scanFolders ( rootFolderPath , folders , folderFileExtensions , callback ) { var result = [ ] ; console . log ( 'Scanning:: Folders' , folders ) ; console . log ( 'Scanning:: Root folder path' , rootFolderPath ) ; var fileExtensions = self . fileExtensions . slice ( ) ; scanFolder ( ) ; function scanFolder ( ) { var folder = folders . shift ( ) ; if ( folder === undefined ) { //                console.log('Scanning:: Finished with result', result); return callback ( null , result ) ; } if ( folderFileExtensions . length ) { fileExtensions = folderFileExtensions . shift ( ) ; } //var path = rootFolderPath + '/' + folder; var path = rootFolderPath + folder ; console . log ( 'Scanning:: Full path to folder' , path , fileExtensions ) ; fs . readdir ( path , function ( err , list ) { if ( err ) { console . error ( "Error scanning folder: " , path ) ; return scanFolder ( ) ; } var files = [ ] ; for ( var i = 0 ; i < list . length ; i ++ ) { if ( acceptFile ( path , list [ i ] , fileExtensions ) ) { //files.push((folder.length ? folder + '/' : folder) + list[i]); files . push ( path + '/' + list [ i ] ) ; } } result = result . concat ( files ) ; scanFolder ( ) ; } ) ; } }
Private functions 
Gets files from folders

@param rootFolderPath
@param folders {Array}
@param callback

@return {Array} array of files
Private functions Gets files from folders