Skip to content

Commit

Permalink
Merge branch 'master' into daniellacosse/pr_from_fork_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse authored Feb 22, 2022
2 parents 579130d + dfbe83b commit b6f2e59
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scripts/environment_json.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,27 @@ import minimist from "minimist";
*/
export async function environmentJson(platform, buildMode) {
if (!platform) {
throw new Error("environmentJson requires a platform argument");
throw new TypeError("environmentJson requires a platform argument");
}

if (!(buildMode === "debug" || buildMode === "release")) {
throw new Error("environmentJson requires a buildMode argument of either 'debug' or 'release'");
throw new TypeError("environmentJson requires a buildMode argument of either 'debug' or 'release'");
}

if (buildMode === "release" && !process.env.SENTRY_DSN) {
throw new Error("Release builds require SENTRY_DSN, but it is not defined.");
if (buildMode === "release") {
if (!process.env.SENTRY_DSN) {
throw new TypeError("Release builds require SENTRY_DSN, but it is not defined.");
}

/*
the SENTRY_DSN follows a stardard URL format:
https://docs.sentry.io/product/sentry-basics/dsn-explainer/#the-parts-of-the-dsn
*/
try {
new URL(process.env.SENTRY_DSN);
} catch (e) {
throw new TypeError(`The SENTRY_DSN ${process.env.SENTRY_DSN} is not a valid URL!`);
}
}

return {
Expand Down

0 comments on commit b6f2e59

Please sign in to comment.