Skip to content

Commit

Permalink
Mirror entire environment under node
Browse files Browse the repository at this point in the history
One can still use `-sDETERMINISITIC` to avoid this behaviour.

Fixes: #18816
  • Loading branch information
sbc100 committed Feb 22, 2023
1 parent fbc5d5c commit 5ff0a48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ See docs/process.md for more on how version tagging works.
3.1.33 (in development)
-----------------------
- Update SDL2_ttf port to 2.20.2 (#18804)
- When running under node the full set of environment variables (i.e.
process.env) are now reflected to running emscripten process (via e.g.
getenv). If you don't want this behaviour `-sDETERMINISTIC` can be used
to disable this can give fake envinonment instead.

3.1.32 - 02/17/23
-----------------
Expand Down
14 changes: 10 additions & 4 deletions src/library_wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ var WasiLibrary = {
$getEnvStrings: function() {
if (!getEnvStrings.strings) {
// Default values.
#if !DETERMINISTIC
// Browser language detection #8751
var lang = ((typeof navigator == 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
#else
#if DETERMINISTIC
// Deterministic language detection, ignore the browser's language.
var lang = 'C.UTF-8';
#else
// Browser language detection #8751
var lang = ((typeof navigator == 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
#endif
var env = {
'USER': 'web_user',
Expand All @@ -58,6 +58,12 @@ var WasiLibrary = {
'LANG': lang,
'_': getExecutableName()
};
#if ENVIRONMENT_MAY_BE_NODE && !DETERMINISTIC
if (ENVIRONMENT_IS_NODE) {
// Under node we mirror then entire outer environment
env = process.env;
}
#endif
// Apply the user-provided values, if any.
for (var x in ENV) {
// x is a key in ENV; if ENV[x] is undefined, that means it was
Expand Down

0 comments on commit 5ff0a48

Please sign in to comment.