Use for..of loops instead of promises

a16d13fd4194c9b3bca1d2350a62f84c9a2d7fdc

Tucker McKnight | Sun Oct 12 2025

Use for..of loops instead of promises

These wait for each other in a sequence, unliked a Promise.all(array.map),
which executes everything all at once. Artifact steps whould be able
to depend on the result of the previous one, so the need to
go in sequence.
main.ts:89
Before
89
90
91
92
93
94
95
96
            Promise.all(repoConfig.branchesToPull.map(async (branch) => {
              return Promise.all(repoConfig.artifactSteps.map(async (artifactStep) => {
                return exec(`cp -r ${tempDirRepoPath}/${artifactStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branch)}/${artifactStep.copyTo}`)
              }))
            })).then(async () => {
              // delete the temp dirs
              await exec(`rm -r ${tempDir}`)
            })
After
89
90
91
92
93
94
95
96
            for (let branch of repoConfig.branchesToPull) {
              for (let artifactStep of repoConfig.artifactSteps) {
                await exec(`cp -r --remove-destination ${tempDirRepoPath}/${artifactStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/branches/${eleventyConfig.getFilter("slugify")(branch)}/${artifactStep.copyTo}`)
              }
            }
            // delete the temp dirs
            await exec(`rm -r ${tempDir}`)