fix(version): Fix file formatting on git add #3796
Merged
+1
−1
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.
Description
PR #3766 brought prettier 3 support by using asynchronous prettier APIs, but missed one
await
when calling.format(...)
.Because of this,
fs.writeFileSync(...)
is called with a Promise instead of a string and throws an exception:This exception is caught by the try/catch, and the file is never written.
Worse, when formatting files that are not supported by prettier (ex: yarn.lock),
.format(...)
fails and the promise rejection isn't handled, which lead to the following exception:and Node terminates the process, which is probably the cause of #3788 and #3773
Motivation and Context
This fixes file formatting and overall crashes during
lerna version
.How Has This Been Tested?
Tested when doing a release in a project that uses lerna 7.1.4 and prettier 3.0.0
Types of changes
Checklist: