From 98788b878f90c6a8ec051d0170b32c4e012d8642 Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Tue, 16 Mar 2021 16:42:04 +0100 Subject: [PATCH] convert *_ROOT env to absolute paths (#3255) fixes #3220 --- content/constants.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/constants.js b/content/constants.js index 0088595db15d..74e8afaee1ba 100644 --- a/content/constants.js +++ b/content/constants.js @@ -10,6 +10,7 @@ let CONTENT_ROOT = process.env.CONTENT_ROOT; if (!CONTENT_ROOT) { throw new Error("Env var CONTENT_ROOT must be set"); } +CONTENT_ROOT = fs.realpathSync(CONTENT_ROOT); if ( path.basename(CONTENT_ROOT) !== "files" && fs.existsSync(path.join(CONTENT_ROOT, "files")) @@ -23,8 +24,8 @@ if ( throw new Error(`${path.resolve(CONTENT_ROOT)} does not exist`); } -const CONTENT_ARCHIVED_ROOT = process.env.CONTENT_ARCHIVED_ROOT; -const CONTENT_TRANSLATED_ROOT = process.env.CONTENT_TRANSLATED_ROOT; +let CONTENT_ARCHIVED_ROOT = process.env.CONTENT_ARCHIVED_ROOT; +let CONTENT_TRANSLATED_ROOT = process.env.CONTENT_TRANSLATED_ROOT; // This makes it possible to know, give a root folder, what is the name of // the repository on GitHub. @@ -41,6 +42,7 @@ if (CONTENT_ARCHIVED_ROOT) { if (!fs.existsSync(CONTENT_ARCHIVED_ROOT)) { throw new Error(`${path.resolve(CONTENT_ARCHIVED_ROOT)} does not exist`); } + CONTENT_ARCHIVED_ROOT = fs.realpathSync(CONTENT_ARCHIVED_ROOT); ROOTS.push(CONTENT_ARCHIVED_ROOT); REPOSITORY_URLS[CONTENT_ARCHIVED_ROOT] = "mdn/archived-content"; } @@ -48,6 +50,7 @@ if (CONTENT_TRANSLATED_ROOT) { if (!fs.existsSync(CONTENT_TRANSLATED_ROOT)) { throw new Error(`${path.resolve(CONTENT_TRANSLATED_ROOT)} does not exist`); } + CONTENT_TRANSLATED_ROOT = fs.realpathSync(CONTENT_TRANSLATED_ROOT); ROOTS.push(CONTENT_TRANSLATED_ROOT); REPOSITORY_URLS[CONTENT_TRANSLATED_ROOT] = "mdn/translated-content"; }