Repository navigation
Exit env-kit.edit cleanly when there is no terminal - #26
Merged
Merged
Conversation
With stdin not a terminal, laravel/prompts returns each prompt's default, and the editor's menu has none, so the first select() threw NonInteractiveValidationException: Required. Check up front instead: under --no-interaction or with no terminal, name the set, unset and rename commands, change nothing, and exit 2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
laranail::env-kit.editruns with no terminal (cron, a CI step, a pipe), it fails with an uncaughtLaravel\Prompts\Exceptions\NonInteractiveValidationException: Required.and a stack trace. Without a TTY, laravel/prompts returns each prompt's default instead of asking. The editor's firstselect()has no default, so its required validation throws.EditCommand::handle()now checkscanPrompt()first. Input must be interactive, which rules out--no-interactionand covers Symfony's own no-TTY detection. Prompts must also be able to ask: either Laravel's question-helper fallback is active (Windows, the test harness) or stdin is a terminal, which is the same check laravel/prompts makes.laranail::env-kit.edit needs an interactive terminal. To change keys without one, use laranail::env-kit.set, laranail::env-kit.unset or laranail::env-kit.rename., changes nothing, and exits2(EXIT_USAGE, from the documented exit-code contract). The editor has no--key/--valueflags; those three commands are the non-interactive path.--force-productionone.[Unreleased]has a Fixed entry.docs/tools/tui.mdhas a new "Without a terminal" section.Tests (
tests/Feature/TuiTest.php)--no-interactionviaartisan(): asserts the full message, exit code 2, no "Closed EnvKit editor.", and the file is unchanged.localenvironment, so Laravel does not answer prompts for the user. It runs the command throughKernel::handle()with stdin set to/dev/null. The test asserts the message, thatRequired.is absent, exit status 2, and that the file is unchanged. It is skipped without POSIX/proc_open, the same asConcurrencyTest.Fail-first, against the old
EditCommand:NonInteractiveValidationException ... Required.;-ncase tried to prompt (askQuestion(), but no expectations were specified);Local: pest 541 passed, phpstan clean, and pint clean against package-tools'
pint.json. Rector is not configured in this repository (norector.php, and not in CI), so it was not run.