fix: not all files are build correctly, when execute in parallel

This commit is contained in:
Paul Werner 2023-09-25 11:12:10 +02:00
parent b24fd4c393
commit 98d89a5296

View file

@ -13,23 +13,22 @@ const files = [
...readdirSync(directoryPathComponents).map((e) => `components/atoms/${e}`), ...readdirSync(directoryPathComponents).map((e) => `components/atoms/${e}`),
]; ];
await Promise.all( for (let file of files) {
files.map(async function (file) { if (file.includes('.ftl')) {
if (file.includes('.ftl')) { // Build using mailwind
// Build using mailwind await exec(
await exec( `mailwind --input-html ${path.join(
`mailwind --input-html ${path.join( __dirname,
__dirname, `../theme/keywind/email/html-src/${file}`
`../theme/keywind/email/html-src/${file}` )} --output-html ${path.join(__dirname, `../theme/keywind/email/html/${file}`)}`
)} --output-html ${path.join(__dirname, `../theme/keywind/email/html/${file}`)}` );
); // fix: wrong build result for ftl-file exception
// fix: wrong build result for ftl-file exception const data = readFileSync(path.join(__dirname, `../theme/keywind/email/html/${file}`));
const data = readFileSync(path.join(__dirname, `../theme/keywind/email/html/${file}`)); const result = data
const result = data.toString() .toString()
.replaceAll("<!--@", '</@') .replaceAll('<!--@', '</@')
.replaceAll("<!--#", '</#') .replaceAll('<!--#', '</#')
.replaceAll("-->", '>') .replaceAll('-->', '>');
writeFileSync(path.join(__dirname, `../theme/keywind/email/html/${file}`), result); writeFileSync(path.join(__dirname, `../theme/keywind/email/html/${file}`), result);
} }
}) }
);