diff --git a/src/factory.ts b/src/factory.ts index 3b9c3ad..1264e02 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -116,15 +116,15 @@ async function getModelFolderContents(model: string): Promise } // Splitting files from localization folders - const bundle = filteredFiles.filter(entry => !entry.includes(".lproj")); + const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj")); const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj")); - const bundleBuffers = bundle.map(file => readFile(path.resolve(model, file))); + const bundleBuffers = rawBundle.map(file => readFile(path.resolve(model, file))); const buffers = await Promise.all(bundleBuffers); - const bundleMap = Object.assign({}, - ...bundle.map((fileName, index) => ({ [fileName]: buffers[index] })) - ) as BundleUnit; + const bundle: BundleUnit = Object.assign({}, + ...rawBundle.map((fileName, index) => ({ [fileName]: buffers[index] })) + ); // Reading concurrently localizations folder // and their files and their buffers @@ -158,7 +158,7 @@ async function getModelFolderContents(model: string): Promise ); return { - bundle: bundleMap, + bundle, l10nBundle }; } @@ -170,17 +170,17 @@ async function getModelFolderContents(model: string): Promise */ function getModelBufferContents(model: BundleUnit): PartitionedBundle { - const bundle = removeHidden(Object.keys(model)).reduce((acc, current) => { + const rawBundle = removeHidden(Object.keys(model)).reduce((acc, current) => { // Checking if current file is one of the autogenerated ones or if its // content is not available - if (/(manifest|signature)/.test(current) || !bundle[current]) { + if (/(manifest|signature)/.test(current) || !rawBundle[current]) { return acc; } return { ...acc, [current]: model[current] }; }, {}); - const bundleKeys = Object.keys(bundle); + const bundleKeys = Object.keys(rawBundle); if (!bundleKeys.length) { throw new Error("Cannot proceed with pass creation: bundle initialized") @@ -189,19 +189,19 @@ function getModelBufferContents(model: BundleUnit): PartitionedBundle { // separing localization folders const l10nFolders = bundleKeys.filter(file => file.includes(".lproj")); const l10nBundle: PartitionedBundle["l10nBundle"] = Object.assign({}, - ...l10nFolders.map(folder => - ({ [folder]: bundle[folder] }) as BundleUnit + ...l10nFolders.map(folder => + ({ [folder]: rawBundle[folder] }) ) ); - const unLocalizedBundle: BundleUnit = Object.assign({}, + const bundle: BundleUnit = Object.assign({}, ...bundleKeys .filter(file => !file.includes(".lproj")) - .map(file => ({ [file]: bundle[file] })) + .map(file => ({ [file]: rawBundle[file] })) ); return { - bundle: unLocalizedBundle, + bundle, l10nBundle }; }