Skip to content

Commit a262b73

Browse files
committed
Avoid setting NODE_ENV when built
1 parent cb98ffb commit a262b73

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/constants.mts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ const LAZY_ENV = () => {
245245
const getConfigValueOrUndef = utils.getConfigValueOrUndef
246246
const readOrDefaultSocketJson = utils.readOrDefaultSocketJson
247247
const GITHUB_TOKEN = envAsString(processEnv['GITHUB_TOKEN'])
248+
const INLINED_SOCKET_CLI_PUBLISHED_BUILD = envAsBoolean(
249+
process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD'],
250+
)
248251
// We inline some environment values so that they CANNOT be influenced by user
249252
// provided environment variables.
250253
return Object.freeze({
@@ -310,9 +313,7 @@ const LAZY_ENV = () => {
310313
),
311314
// Comp-time inlined flag to determine if this is a published build.
312315
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD']".
313-
INLINED_SOCKET_CLI_PUBLISHED_BUILD: envAsBoolean(
314-
process.env['INLINED_SOCKET_CLI_PUBLISHED_BUILD'],
315-
),
316+
INLINED_SOCKET_CLI_PUBLISHED_BUILD,
316317
// Comp-time inlined flag to determine if this is the Sentry build.
317318
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']".
318319
INLINED_SOCKET_CLI_SENTRY_BUILD: envAsBoolean(
@@ -342,6 +343,12 @@ const LAZY_ENV = () => {
342343
NODE_COMPILE_CACHE: constants.SUPPORTS_NODE_COMPILE_CACHE_ENV_VAR
343344
? constants.socketCachePath
344345
: '',
346+
// Redefine registryConstants.ENV.NODE_ENV to account for the
347+
// INLINED_SOCKET_CLI_PUBLISHED_BUILD environment variable.
348+
NODE_ENV:
349+
envAsString(processEnv['NODE_ENV']).toLowerCase() === 'production'
350+
? 'production'
351+
: (INLINED_SOCKET_CLI_PUBLISHED_BUILD ? '' : 'development'),
345352
// Well known "root" CAs (like VeriSign) will be extended with the extra
346353
// certificates in file. The file should consist of one or more trusted
347354
// certificates in PEM format.

0 commit comments

Comments
 (0)