From 1d6af94cfb0f2495d3ae064fc3a76a6db48446de Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Sat, 17 Apr 2021 20:19:46 +0300 Subject: [PATCH] test(docs-infra): ignore empty lines in `URLS_TO_REDIRECT.txt` (#41680) Previously, the `URLS_TO_REDIRECT.txt` file was expected to not contain any empty lines. This could easily result in test errors when updating the file, since it is common for IDEs/editors to automatically ensure there is an empty line at the end of a saved file ([example failure][1]). This commit updates the test helpers to be able to cope with empty or whitespace-only lines in `URLS_TO_REDIRECT.txt` by ignoring such lines. [1]: https://circleci.com/gh/angular/angular/965534 PR Close #41680 --- aio/tests/deployment/shared/URLS_TO_REDIRECT.txt | 2 +- aio/tests/deployment/shared/helpers.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aio/tests/deployment/shared/URLS_TO_REDIRECT.txt b/aio/tests/deployment/shared/URLS_TO_REDIRECT.txt index 9c1fbb3be6..72cd4a326a 100644 --- a/aio/tests/deployment/shared/URLS_TO_REDIRECT.txt +++ b/aio/tests/deployment/shared/URLS_TO_REDIRECT.txt @@ -194,4 +194,4 @@ /start/forms /start/start-forms /start/routing /start/start-routing /testing /guide/testing -/testing/first-app-tests.html /guide/testing \ No newline at end of file +/testing/first-app-tests.html /guide/testing diff --git a/aio/tests/deployment/shared/helpers.ts b/aio/tests/deployment/shared/helpers.ts index b4d8af5bea..f127aff012 100644 --- a/aio/tests/deployment/shared/helpers.ts +++ b/aio/tests/deployment/shared/helpers.ts @@ -41,7 +41,10 @@ export function loadRedirects(): FirebaseRedirectConfig[] { export function loadLegacyUrls() { const pathToLegacyUrls = `${__dirname}/URLS_TO_REDIRECT.txt`; - const urls = readFileSync(pathToLegacyUrls, 'utf8').split('\n').map(line => line.split('\t')); + const urls = readFileSync(pathToLegacyUrls, 'utf8') + .split('\n') + .filter(line => line.trim() !== '') + .map(line => line.split('\t')); return urls; }