Skip to content

Commit

Permalink
convert *_ROOT env to absolute paths (#3255)
Browse files Browse the repository at this point in the history
fixes #3220
  • Loading branch information
fiji-flo authored Mar 16, 2021
1 parent 56cb99f commit 98788b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions content/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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.
Expand All @@ -41,13 +42,15 @@ 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";
}
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";
}
Expand Down

0 comments on commit 98788b8

Please sign in to comment.