Skip to content

Commit 0d32425

Browse files
committed
fix(publish): handle already-published error gracefully during publish
- Catch E400 'Cannot publish over previously published version' errors - Skip packages that were already published instead of failing - Improves robustness when re-running publish workflows
1 parent 9fd0d55 commit 0d32425

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scripts/publish.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ const publishPackage = async (dir: string, displayName: string): Promise<'publis
131131
log(`✅ ${dryRun ? 'Dry-run' : 'Published'} ${displayName}@${pkgVersion}`);
132132
return 'published';
133133
} catch (error) {
134+
// Check if it's an "already published" error
135+
const errorStr = String(error);
136+
if (errorStr.includes('Cannot publish over previously published version') ||
137+
errorStr.includes('You cannot publish over the previously published versions')) {
138+
log(`⏭️ Skipping ${displayName}@${pkgVersion} (already published - detected during publish attempt)`);
139+
return 'skipped';
140+
}
141+
134142
console.error(`❌ Failed to publish ${displayName}@${pkgVersion}`);
135143
console.error(`Error details:`, error);
136144
throw error; // Re-throw to stop the script

0 commit comments

Comments
 (0)