diff --git a/bin/buildDrops.js b/bin/buildDrops.js index 28c6bad..3fdc3f0 100644 --- a/bin/buildDrops.js +++ b/bin/buildDrops.js @@ -47,17 +47,31 @@ const buildDrop = (dropName) => { return new Promise((resolve, reject) => { console.log(`Building drop: ${dropName}`) - const child = spawn('npm', ['run', 'build', '-w', `drops/${dropName}`], { - stdio: 'inherit', - shell: true, - }) + // Remove old build to prevent stale output from being used + const buildDir = path.join(__dirname, `../app/public/drops/${dropName}`) + if (fs.existsSync(buildDir)) { + fs.rmSync(buildDir, { recursive: true }) + } + + const child = spawn( + 'npm', + ['run', 'build', '-w', `drops/${dropName}`], + { + stdio: 'inherit', + shell: true, + }, + ) child.on('close', (code) => { if (code === 0) { console.log(`✓ Successfully built: ${dropName}`) resolve() } else { - reject(new Error(`Failed to build ${dropName} (exit code ${code})`)) + reject( + new Error( + `Failed to build ${dropName} (exit code ${code})`, + ), + ) } }) @@ -76,7 +90,10 @@ const buildAllPublishedDrops = async () => { return } - console.log(`Found ${publishedDrops.length} published drop(s):`, publishedDrops) + console.log( + `Found ${publishedDrops.length} published drop(s):`, + publishedDrops, + ) console.log('Starting builds...\n') for (const dropName of publishedDrops) {