Added first support to localization L10N, now localized folders get recognized, indexed, and their files sha1-calculated

This commit is contained in:
Alexander Cerutti
2018-06-11 23:55:08 +02:00
parent 006a0270d3
commit a7590b09dd

View File

@@ -251,7 +251,9 @@ function generatePass(options) {
}); });
} }
fs.readdir(path.resolve(Configuration.passModelsDir, `${options.modelName}.pass`), function(err, files) { let modelPath = path.resolve(Configuration.passModelsDir, `${options.modelName}.pass`);
fs.readdir(modelPath, function(err, files) {
if (err) { if (err) {
return reject({ return reject({
status: false, status: false,
@@ -264,8 +266,6 @@ function generatePass(options) {
// Removing hidden files and folders // Removing hidden files and folders
let list = removeHiddenFiles(files).filter(f => !f.includes(".lproj")); let list = removeHiddenFiles(files).filter(f => !f.includes(".lproj"));
// Getting only folders
let folderList = files.filter(f => f.includes(".lproj"));
if (!list.length) { if (!list.length) {
return reject({ return reject({
@@ -287,6 +287,29 @@ function generatePass(options) {
}); });
} }
// Getting only folders
let folderList = files.filter(f => f.includes(".lproj"));
// I may have (and I rathered) used async.concat to achieve this but it returns a list of filenames ordered by folder.
// The problem rise when I have to understand which is the first file of a folder which is not the first one.
// By doing this way, I get an Array containing an array of filenames for each folder.
let folderExtractors = folderList.map(f => function(callback) {
let l10nPath = path.join(modelPath, f);
fs.readdir(l10nPath, function(err, list) {
if (err) {
return callback(err, null);
}
let filteredFiles = removeHiddenFiles(list);
return callback(null, filteredFiles);
});
});
async.parallel(folderExtractors, function(err, listByFolder) {
listByFolder.forEach((folder, index) => folder.forEach(f => list.push(path.join(folderList[index], f)) ) )
let manifest = {}; let manifest = {};
let archive = archiver("zip"); let archive = archiver("zip");
@@ -368,6 +391,7 @@ function generatePass(options) {
}); });
}); });
}); });
});
} }
function init(configPath) { function init(configPath) {