Repository navigation
feat(manifest): drop the line of an empty placeholder with omitLineIfEmpty - #25
Merged
Merged
Conversation
…Empty A placeholder on its own line that resolves to "" left an empty line behind. Payload templates had to place each optional hook where a blank line would be, and a hook that missed this added stray blank lines to every consumer's file, showing up as whitespace-only diffs on upgrade. With omitLineIfEmpty: true, a line holding only the token is removed when the value is empty. Opt-in per placeholder, so existing renders stay byte-identical. Needs manifest schemaVersion 4; 2 and 3 still parse, and the loader refuses the key under an older version so a forgotten bump fails loud.
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.
What
Adds an opt-in
omitLineIfEmptyflag to render placeholders. When it is set and the value resolves to"", a line that holds only the token (plus spaces, tabs or a trailing CR) is removed instead of rendering as a blank line. A token that shares its line with other text substitutes as before, and token lines brought in through another placeholder's value are caught too.The flag needs manifest
schemaVersion4. Versions 2 and 3 still parse, so existing payloads render byte-identical. A payload that uses the flag under an older version fails withCONFIG_INVALIDnaming the placeholder, so a forgotten bump doesn't ship a payload that every older CLI rejects with a raw zod error.Why
Optional hooks like the Dockerfile's
docker.preInstallordocker.finalStageSetupdefault to""and leave an empty line in every consumer's file when unused. Templates had to put each hook where a blank line would sit anyway, and a hook that didn't added stray blank lines that show up as whitespace-only diffs on upgrade.Tried against base-config's payload with the flag on the four Dockerfile hooks: empty hooks drop exactly those four lines, set hooks land in place, and
checkstays clean.