From ea2d453118f3088bd187e0d7cf04f8339772de4d Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 3 Jun 2019 21:39:30 +0300 Subject: [PATCH] fix(ivy): ngcc - use spaces in overwritten `package.json` content for readability (#30831) When ngcc processes an entrypoint, it updates `package.json` with metadata about the processed format. Previously, it overwrote the `package.json` with the stringified JSON object without spaces. This made the file difficult to read (for example when looking at the file while debugging an ngcc failure). This commit fixes it by using spaces in the new `package.json` content. PR Close #30831 --- integration/ngcc/test.sh | 12 ++++++------ .../compiler-cli/ngcc/src/packages/build_marker.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/ngcc/test.sh b/integration/ngcc/test.sh index 5374cc70fe..6f573e5ed8 100755 --- a/integration/ngcc/test.sh +++ b/integration/ngcc/test.sh @@ -14,23 +14,23 @@ if [[ $? != 0 ]]; then exit 1; fi # Did it add the appropriate build markers? # - esm2015 - grep '"__processed_by_ivy_ngcc__":[^}]*"esm2015":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"esm2015": "' if [[ $? != 0 ]]; then exit 1; fi # - fesm2015 - grep '"__processed_by_ivy_ngcc__":[^}]*"fesm2015":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"fesm2015": "' if [[ $? != 0 ]]; then exit 1; fi - grep '"__processed_by_ivy_ngcc__":[^}]*"es2015":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"es2015": "' if [[ $? != 0 ]]; then exit 1; fi # - esm5 - grep '"__processed_by_ivy_ngcc__":[^}]*"esm5":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"esm5": "' if [[ $? != 0 ]]; then exit 1; fi # - fesm5 - grep '"__processed_by_ivy_ngcc__":[^}]*"module":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"module": "' if [[ $? != 0 ]]; then exit 1; fi - grep '"__processed_by_ivy_ngcc__":[^}]*"fesm5":"' node_modules/@angular/common/package.json + cat node_modules/@angular/common/package.json | awk 'ORS=" "' | grep '"__processed_by_ivy_ngcc__":[^}]*"fesm5": "' if [[ $? != 0 ]]; then exit 1; fi # Did it replace the PRE_R3 markers correctly? diff --git a/packages/compiler-cli/ngcc/src/packages/build_marker.ts b/packages/compiler-cli/ngcc/src/packages/build_marker.ts index c55dbd39c1..8445854e04 100644 --- a/packages/compiler-cli/ngcc/src/packages/build_marker.ts +++ b/packages/compiler-cli/ngcc/src/packages/build_marker.ts @@ -51,5 +51,5 @@ export function markAsProcessed( format: EntryPointJsonProperty) { if (!packageJson.__processed_by_ivy_ngcc__) packageJson.__processed_by_ivy_ngcc__ = {}; packageJson.__processed_by_ivy_ngcc__[format] = NGCC_VERSION; - fs.writeFile(packageJsonPath, JSON.stringify(packageJson)); + fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)); }