Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 525ddcb

Browse filesBrowse files
committed
fix(@schematics/angular): only overwrite JSON file if actually changed
The JSON file helper utility used within the Angular schematics now contains additional checks when attempting to modify a file to avoid overwriting a file if no actual changes will occur after a modify request. (cherry picked from commit 664e6c7)
1 parent e5efdc5 commit 525ddcb
Copy full SHA for 525ddcb

File tree

Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed

‎packages/schematics/angular/utility/json-file.ts

Copy file name to clipboardExpand all lines: packages/schematics/angular/utility/json-file.ts
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,16 @@ export class JSONFile {
9595
},
9696
});
9797

98-
this.content = applyEdits(this.content, edits);
99-
this.host.overwrite(this.path, this.content);
100-
this._jsonAst = undefined;
98+
if (edits.length > 0) {
99+
const editedContent = applyEdits(this.content, edits);
100+
101+
// Update the file content if it changed
102+
if (editedContent !== this.content) {
103+
this.content = editedContent;
104+
this.host.overwrite(this.path, editedContent);
105+
this._jsonAst = undefined;
106+
}
107+
}
101108
}
102109

103110
remove(jsonPath: JSONPath): void {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.