fix(core): do not add an ending new line when serializing a json (#23440)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #19315
This commit is contained in:
Leosvel Pérez Espinosa 2024-05-16 17:44:51 +02:00 committed by GitHub
parent 381e5cd494
commit 5757350ebd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -38,7 +38,8 @@ export function writeJson<T extends object = object>(
value: T,
options?: JsonSerializeOptions
): void {
tree.write(path, serializeJson(value, options));
const serialized = serializeJson(value, options);
tree.write(path, `${serialized}\n`);
}
/**

View File

@ -96,5 +96,5 @@ export function serializeJson<T extends object = object>(
input: T,
options?: JsonSerializeOptions
): string {
return JSON.stringify(input, null, options?.spaces ?? 2) + '\n';
return JSON.stringify(input, null, options?.spaces ?? 2);
}