Skip to content

Commit

Permalink
fix(@schematics/angular): polyfills migration leaving broken code in …
Browse files Browse the repository at this point in the history
…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 angular#14443
  • Loading branch information
Alan Agius authored and mgechev committed May 17, 2019
1 parent c402903 commit c81adbd
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c81adbd

Please sign in to comment.