feat: conditionally format target JSON file after updating version - #27
Open
jorenbroekema wants to merge 1 commit into
Open
feat: conditionally format target JSON file after updating version#27jorenbroekema wants to merge 1 commit into
jorenbroekema wants to merge 1 commit into
Conversation
jorenbroekema
commented
Jul 30, 2026
| delete process.env.BUILD_REASON; | ||
| delete process.env.BUILD_SOURCEBRANCH; | ||
| delete process.env.BUILD_SOURCEVERSION; | ||
| process.argv = []; |
Author
There was a problem hiding this comment.
we weren't cleaning this up properly so my added test was failing at the end of the file but succeeding if I put it at the top of the file.
jorenbroekema
commented
Jul 30, 2026
| setup('Ci Individual', 'refs/heads/master', '1c2abf44a3b28c5f4385d95b9f3fe83a1af94397', '0.0.1'); | ||
|
|
||
| try { | ||
| const result = simpleVersioner(); |
jorenbroekema
commented
Jul 30, 2026
| jsonFile.version = version; | ||
| fs.writeFileSync(filePath, JSON.stringify(jsonFile, null, 4)); | ||
| if (shouldRunPrettier(filePath)) { | ||
| // log it, actually useful if the user is aware that prettier was ran on the file that we updated |
Author
There was a problem hiding this comment.
not just that, also makes it easy to verify in a test with a mock that prettier was ran 😅 without actually running prettier, by spying on the log
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.
We noticed a user had failing pipelines because simple-versioner is setting the version of their package.json, and later in the same pipeline they run a linting step that verifies that files are prettier formatted.
In simple-versioner, the JSON file is set with JSON.stringify() and 4 spaces indentation, but depending on the user's prettier settings, they may use tabs or different amount of spaces.
I've added a feature that identifies whether the user has a prettier installation and a prettier config is available for the target JSON file that simple-versioner adjusts the version field of. If this is the case, it adds a prettier format command afterwards, to ensure it's formatted according to the user's preferences. This way, pipeline happy :).