Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
fix(): remove redundant await in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined committed Sep 23, 2021
1 parent e9ef9e1 commit 01b6ec9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/release/copyReleaseToProject.js
Expand Up @@ -17,12 +17,11 @@ async function main() {
// Get pluggable widget folders containing "-native"
const widgetFolderNames = await asyncFilter(await readdir(pluggableWidgetsFolderPath), isNativeWidgetFolder);
const mpkPathsToCopy = [];
for await (const widgetFolderName of widgetFolderNames) {
for (const widgetFolderName of widgetFolderNames) {
const widgetDistFolderPath = join(pluggableWidgetsFolderPath, widgetFolderName, "dist");
const widgetDistFolderNames = await readdir(widgetDistFolderPath);
const allMpkPaths = [];

for await (const widgetDistFolderName of widgetDistFolderNames) {
for (const widgetDistFolderName of await readdir(widgetDistFolderPath)) {
// Check if folder name contains versioning
if (!/\d+\.\d+\.\d+/.test(widgetDistFolderName)) {
continue;
Expand All @@ -46,14 +45,17 @@ async function main() {
console.log(
`Finished copying ${mpkPathsToCopy.length} widgets to Mendix project ${basename(process.env.MX_PROJECT_PATH)}`
);
};
}

async function asyncFilter(array, fn) {
return Promise.all(array.map(fn)).then(booleans => array.filter((_, i) => booleans[i]));
}

async function isNativeWidgetFolder(widgetFolderName) {
return widgetFolderName.includes("-native") && (await stat(join(pluggableWidgetsFolderPath, widgetFolderName))).isDirectory();
return (
widgetFolderName.includes("-native") &&
(await stat(join(pluggableWidgetsFolderPath, widgetFolderName))).isDirectory()
);
}

async function getFileModifiedTime(path) {
Expand Down

0 comments on commit 01b6ec9

Please sign in to comment.