File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,15 @@ if command -v fvm &>/dev/null; then
3232fi
3333
3434DRY_FLAG=" "
35+ FORCE_FLAG=" "
3536if [[ " $MODE " == " dry-run" ]]; then
3637 DRY_FLAG=" --dry-run"
3738 echo " ▶ DRY-RUN mode — no packages will be uploaded"
3839else
3940 echo " ▶ PUBLISH mode — packages will be uploaded to pub.dev"
4041 read -rp " Continue? [y/N] " confirm
4142 [[ " $confirm " =~ ^[Yy]$ ]] || { echo " Aborted." ; exit 1; }
43+ FORCE_FLAG=" --force" # skip dart pub publish's own y/N prompt
4244fi
4345
4446# ── Helpers ──────────────────────────────────────────────────────────────────
@@ -106,13 +108,18 @@ publish_package() {
106108
107109 patch_pubspec " $dir "
108110
111+ # Ensure pubspec is restored even if the publish command fails or the
112+ # script is interrupted (Ctrl-C, set -e abort, etc.)
113+ trap " restore_pubspec '$dir '" EXIT
114+
109115 (
110116 cd " $dir "
111- echo " Running: dart pub publish $DRY_FLAG "
112- $FLUTTER pub publish $DRY_FLAG
117+ echo " Running: dart pub publish $DRY_FLAG $FORCE_FLAG "
118+ $FLUTTER pub publish $DRY_FLAG $FORCE_FLAG
113119 )
114120
115121 restore_pubspec " $dir "
122+ trap - EXIT # clear trap after successful restore
116123}
117124
118125# ── Static analysis first ─────────────────────────────────────────────────────
You can’t perform that action at this time.
0 commit comments