Skip to content

Commit

Permalink
Catch errors when building instances
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jan 18, 2024
1 parent 0dbed5f commit 957fac6
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,39 @@ const updatedBranches = new Set()

for (const { name, configFile, branch } of instances) {
console.log(`Cocoda Instance: ${name} (branch/tag: ${branch}, config: ${configFile ?? "none"})`)
if (await fs.pathExists(`${targetFolder}/${name}`)) {
// No updates for non-branches
if (branch.match(/^\d/)) {
console.log("- instance already built and no updates necessary")
continue
try {
if (await fs.pathExists(`${targetFolder}/${name}`)) {
// No updates for non-branches
if (branch.match(/^\d/)) {
console.log("- instance already built and no updates necessary")
continue
}

// Skip if there are no changes with origin
await $`git fetch`.quiet()
const diff = await $`git diff ${branch} origin/${branch}`.quiet()
if (!`${diff}`.trim() && !updatedBranches.has(branch)) {
console.log("- instance already built and no updates necessary")
continue
}
updatedBranches.add(branch)
console.log(`- There's an update to branch ${branch}. Pulling changes and rebuilding Cocoda...`)
await $`git pull origin ${branch}`.quiet()
}

// Skip if there are no changes with origin
await $`git fetch`.quiet()
const diff = await $`git diff ${branch} origin/${branch}`.quiet()
if (!`${diff}`.trim() && !updatedBranches.has(branch)) {
console.log("- instance already built and no updates necessary")
continue
// Build version via build-all.sh script
await $`./build/build-all.sh ${branch}`
// Move files to target folder
if (await fs.pathExists(`${targetFolder}/${name}`)) {
await $`rm -r ${targetFolder}/${name}`
}
updatedBranches.add(branch)
console.log(`- There's an update to branch ${branch}. Pulling changes and rebuilding Cocoda...`)
await $`git pull origin ${branch}`.quiet()
}
// Build version via build-all.sh script
await $`./build/build-all.sh ${branch}`
// Move files to target folder
if (await fs.pathExists(`${targetFolder}/${name}`)) {
await $`rm -r ${targetFolder}/${name}`
}
await $`mv releases/${branch} ${targetFolder}/${name}`
// Link config file if needed
if (configFile) {
await $`rm ${targetFolder}/${name}/cocoda.json`
await $`ln -s ${configFile} ${targetFolder}/${name}/cocoda.json`
await $`mv releases/${branch} ${targetFolder}/${name}`
// Link config file if needed
if (configFile) {
await $`rm ${targetFolder}/${name}/cocoda.json`
await $`ln -s ${configFile} ${targetFolder}/${name}/cocoda.json`
}
console.log(`- Successfully built instance ${name}!`)
} catch (error) {
console.error(`- Error building instance ${name}: ${error}`)
}
console.log(`- Successfully built instance ${name}!`)
}

0 comments on commit 957fac6

Please sign in to comment.