I am using gradle to build localized files. I have total 7 languages to build. Write now I am using async/await to build for the localized files and it is working fine. It is building in a sequence but a single language to build it take approx. 4 minutes to build.
What i want instead of calling the method in a sequence can it be called in parallel, so that the build time can be reduced.
Below is the code snippet:
“`
const configuration = require(path.resolve(“./tools/build-all.configuration.json”)); // Place from where reading all the languages to build
buildVersions(version).then(() => {
console.log(“Building all language is done.”);
});
async function buildVersions(buildId) {
return new Promise(async accept => {
try {
await buildLanguageVersions(
configuration.localeBuildData.availableLocales.map(language => language.code)
);
} catch (es) {
console.error(es);
}
// writing to file and some operation
accept();
});
}
function buildLanguageVersions(buildLanguages) {
return new Promise(async (accept, reject) => {
const allLanguage = [];
for (let language of buildLanguages) {
const ret = await buildALanguage(language);
allLanguage .push(ret);
}
accept(allLanguage );
});
}
function buildALanguage(buildLanguage) {
return new Promise(accept => {
console.log(” Building a language ” + buildLanguage);
const languagePath = path.resolve(`./src/i18n/messages.${buildLanguage}.xlf`);
const languageFile = fs.existsSync(languagePath) ? buildLanguage : “en”;
if (languageFile !== buildLanguage && !fs.existsSync(languagePath)) {
console.error(
“Language file does not exist. Building with english default version.
);
}
//
// Here doing all the operation to build the language file
// and some operation
exec.exec(`${folder} build –configuration=dynamic`, (error, stdout, stderror) => {
if (error) {
throw “Build failed: ” + error;
}
accept(buildLanguage);
});
});
}
Is there any way I can call the _buildALanguage()_buildLanguageVersions()
Error which I am getting:
14:31:17 ERROR in ngcc is already running at process with id 5252.
14:31:17 If you are running multiple builds in parallel then you should pre-process your node_modules via the command line ngcc tool before starting the builds;
I have checked and removes those files but even though everytime I do the build, i get those errors.
Please excuse the typos.