Skip to content

Commit

Permalink
fix(core): do not add an ending new line when serializing a json (#23440
Browse files Browse the repository at this point in the history
)

<!-- 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
  • Loading branch information
leosvelperez committed May 16, 2024
1 parent 381e5cd commit 5757350
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/nx/src/generators/utils/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/utils/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 5757350

Please sign in to comment.