-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7fc025
commit ff2a4ee
Showing
2 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Decide if the currently running process is part of the build phase or happening at runtime. | ||
*/ | ||
export function isBuild(): boolean { | ||
// During build, the main process is invoked by | ||
// `node next build` | ||
// and child processes are invoked as | ||
// `node <path>/node_modules/.../jest-worker/processChild.js`. | ||
// The former is (obviously) easy to recognize, but the latter could happen at runtime as well. Fortunately, the main | ||
// process hits this file before any of the child processes do, so we're able to set an env variable which the child | ||
// processes can then check. During runtime, the main process is invoked as | ||
// `node next start` | ||
// or | ||
// `node /var/runtime/index.js`, | ||
// so we never drop into the `if` in the first place. | ||
if (process.argv.includes('build') || process.env.SENTRY_BUILD_PHASE) { | ||
process.env.SENTRY_BUILD_PHASE = 'true'; | ||
return true; | ||
} | ||
|
||
return false; | ||
} |