Tolerant env vars (#22948)

pull/22949/head
Wendelin 2024-11-21 18:26:51 +01:00 committed by GitHub
parent 43911ef3be
commit 6cc6d9fb45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -2,9 +2,11 @@ const fs = require("fs");
const path = require("path");
const paths = require("./paths.cjs");
const isTrue = (value) => value === "1" || value?.toLowerCase() === "true";
module.exports = {
useWDS() {
return process.env.WDS === "1";
return isTrue(process.env.WDS);
},
isProdBuild() {
return (
@ -12,13 +14,13 @@ module.exports = {
);
},
isStatsBuild() {
return process.env.STATS === "1";
return isTrue(process.env.STATS);
},
isTestBuild() {
return process.env.IS_TEST === "true";
return isTrue(process.env.IS_TEST);
},
isNetlify() {
return process.env.NETLIFY === "true";
return isTrue(process.env.NETLIFY);
},
version() {
const version = fs
@ -30,6 +32,6 @@ module.exports = {
return version[1];
},
isDevContainer() {
return process.env.DEV_CONTAINER === "1";
return isTrue(process.env.DEV_CONTAINER);
},
};