From aa0d83efe4be2672bf8472932a04c69db9962c9b Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 16 May 2019 16:00:06 +0200 Subject: [PATCH] fix(@schematics/angular): polyfills migration leaving broken code in windows Replacment of line endings should only happen to increase the hash matches as otherwise the recorder will fail to update the correct positions Fixes #14443 --- .../angular/migrations/update-8/drop-es6-polyfills.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/schematics/angular/migrations/update-8/drop-es6-polyfills.ts b/packages/schematics/angular/migrations/update-8/drop-es6-polyfills.ts index 862050c1a9b5..d7442b4819c1 100644 --- a/packages/schematics/angular/migrations/update-8/drop-es6-polyfills.ts +++ b/packages/schematics/angular/migrations/update-8/drop-es6-polyfills.ts @@ -78,12 +78,11 @@ function dropES2015PolyfillsFromFile(polyfillPath: string): Rule { return; } - // normalize line endings to increase hash match chances - const content = source.toString().replace(/\r\n|\r/g, '\n'); - + const content = source.toString(); // Check if file is unmodified, if so then replace and return const hash = createHash('md5'); - hash.update(content); + // normalize line endings to increase hash match chances + hash.update(content.replace(/\r\n|\r/g, '\n')); const digest = hash.digest('hex'); if (knownPolyfillHashes.includes(digest)) { // Replace with new project polyfills file