Skip to content

Comments

feat(dev): add option --on-exit=remove#13342

Merged
czubocha merged 5 commits intomainfrom
codex/assess-onexit-enum-option
Feb 12, 2026
Merged

feat(dev): add option --on-exit=remove#13342
czubocha merged 5 commits intomainfrom
codex/assess-onexit-enum-option

Conversation

@czubocha
Copy link
Contributor

@czubocha czubocha commented Feb 11, 2026

Summary

  • Replace the serverless dev exit flag from --remove-on-exit to --on-exit in packages/serverless/lib/cli/commands-schema.js
  • Enforce enum-like validation so only --on-exit=remove is accepted in packages/serverless/lib/plugins/aws/dev/index.js
  • Keep default exit behavior unchanged when --on-exit is omitted (show reminder warning)
  • Update AWS dev CLI docs in docs/sf/providers/aws/cli-reference/dev.md
  • Add unit tests for valid and invalid --on-exit values in packages/serverless/test/unit/lib/plugins/aws/dev.test.js

Test plan

  • npm run test:unit -w @serverless/framework -- packages/serverless/test/unit/lib/plugins/aws/dev.test.js
  • Verified: 1 passed, 1 total suite and 3 passed, 3 total tests

How to test

  1. Run serverless dev --on-exit=remove, press Ctrl+C, and confirm the remove prompt appears.
  2. Run serverless dev --on-exit=foo and confirm it fails with INVALID_DEV_ON_EXIT_OPTION.
  3. Run serverless dev without --on-exit and confirm the default reminder warning is shown on exit.
  4. Run serverless dev --remove-on-exit and confirm the option is rejected as unsupported.

Summary by CodeRabbit

  • Documentation

    • Updated CLI docs to reflect the dev command flag syntax change to --on-exit=remove.
  • Chores

    • Renamed the dev command option to --on-exit and changed its expected value format to a string (accepting "remove") with input validation.
  • Tests

    • Added unit tests covering valid, missing, and invalid values for the new --on-exit option.

@Mmarzex
Copy link
Contributor

Mmarzex commented Feb 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

The dev command option --remove-on-exit was replaced by --on-exit which accepts the string value "remove"; docs, CLI schema, plugin logic (validation and exit handling), and unit tests were updated accordingly.

Changes

Cohort / File(s) Summary
Documentation
docs/sf/providers/aws/cli-reference/dev.md
Updated CLI reference to show --on-exit=remove instead of --remove-on-exit.
CLI Schema
packages/serverless/lib/cli/commands-schema.js
Renamed option from remove-on-exit (boolean) to on-exit (string) and updated usage text to expect a string value (e.g., "remove").
Plugin Implementation
packages/serverless/lib/plugins/aws/dev/index.js
Added validateOnExitOption() to enforce on-exit === "remove"; replaced boolean flag checks with on-exit === 'remove' in dev startup and SIGINT exit handling.
Tests
packages/serverless/test/unit/lib/plugins/aws/dev.test.js
Added unit tests (+94 lines) covering: no option provided, on-exit: "remove" accepted, and invalid values rejected with error code INVALID_DEV_ON_EXIT_OPTION.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nibble flags and tidy rows,
A boolean hops where string now goes,
"remove" I whisper, checked with care,
Dev exits tidy, neat, and fair. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(dev): add option --on-exit=remove' accurately and concisely describes the main change: introducing a new --on-exit=remove option for the dev command, replacing the previous --remove-on-exit flag.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/assess-onexit-enum-option

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@czubocha czubocha changed the title codex/assess-onexit-enum-option feat(dev): add option --on-exit=remove Feb 11, 2026
@czubocha czubocha requested a review from eahefnawy February 11, 2026 17:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/serverless/test/unit/lib/plugins/aws/dev.test.js`:
- Around line 80-92: The test currently validates the thrown message but then
uses a try/catch that won’t fail if validateOnExitOption() stops throwing;
update the test for awsDev.validateOnExitOption() so it asserts both the thrown
message and the error.code in one check — either call validateOnExitOption()
inside a try/catch that calls fail() if no error is thrown and then assert
caughtError.code === 'INVALID_DEV_ON_EXIT_OPTION', or use Jest’s expect(() =>
awsDev.validateOnExitOption()).toThrow() variant that inspects the thrown error
and asserts its message and code together; ensure you reference
awsDev.options['on-exit'] === 'foo' and the error code
'INVALID_DEV_ON_EXIT_OPTION' in the assertion.

@czubocha czubocha merged commit aa05d6c into main Feb 12, 2026
12 checks passed
@czubocha czubocha deleted the codex/assess-onexit-enum-option branch February 12, 2026 00:02
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants