Use for..of loops instead of promises

a16d13fd4194c9b3bca1d2350a62f84c9a2d7fdc

Tucker McKnight <tucker@pangolin.lan> | 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
            const tempDirRepoPath = `${tempDir}/${eleventyConfig.getFilter("slugify")(repoName)}`
            const mkdirresult = await exec(`mkdir ${tempDir}`)
            await exec(`git clone -s ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}.git ${tempDirRepoPath}`)
            Promise.all(repoConfig.branchesToPull.map(async (branch) => {
              await exec(`(cd ${tempDirRepoPath} && git checkout ${branch})`)
              return Promise.all(repoConfig.artifactSteps.map(async (artifactStep) => {
                // Run the command for each step in each branch
                await exec(`(cd ${tempDirRepoPath} && ${artifactStep.command})`)
                // Copy the specified folders from the "from" to the "to" dir
                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
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
            const tempDirRepoPath = `${tempDir}/${eleventyConfig.getFilter("slugify")(repoName)}`
            const mkdirresult = await exec(`mkdir ${tempDir}`)
            await exec(`git clone -s ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}.git ${tempDirRepoPath}`)
            for (let branch of repoConfig.branchesToPull) {
              await exec(`(cd ${tempDirRepoPath} && git checkout ${branch})`)
              for (let artifactStep of repoConfig.artifactSteps) {
                // Run the command for each step in each branch
                await exec(`(cd ${tempDirRepoPath} && ${artifactStep.command})`)
                // Copy the specified folders from the "from" to the "to" dir
                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}`)
⁣
          }
        }
      }