Skip to content

Commit 8edc72a

Browse files
committed
put shell checks for environment out of the ifs
1 parent dfbc24e commit 8edc72a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/shell.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ if (!ENVIRONMENT_IS_PTHREAD) PthreadWorkerInit = {};
9494
var currentScriptUrl = (typeof document !== 'undefined' && document.currentScript) ? document.currentScript.src : undefined;
9595
#endif
9696

97-
if (ENVIRONMENT_IS_NODE) {
9897
#if ENVIRONMENT_MAY_BE_NODE
98+
if (ENVIRONMENT_IS_NODE) {
9999
// Expose functionality in the same simple way that the shells work
100100
// Note that we pollute the global namespace here, otherwise we break in node
101101
var nodeFS;
@@ -162,10 +162,10 @@ if (ENVIRONMENT_IS_NODE) {
162162
#if ASSERTIONS
163163
throw new Error('runtime environment is node, but not compiled with support for that');
164164
#endif // ASSERTIONS
165+
} else
165166
#endif // ENVIRONMENT_MAY_BE_NODE
166-
}
167-
else if (ENVIRONMENT_IS_SHELL) {
168167
#if ENVIRONMENT_MAY_BE_SHELL
168+
if (ENVIRONMENT_IS_SHELL) {
169169
if (typeof read != 'undefined') {
170170
Module['read'] = function shell_read(f) {
171171
#if SUPPORT_BASE64_EMBEDDING
@@ -209,10 +209,10 @@ else if (ENVIRONMENT_IS_SHELL) {
209209
#if ASSERTIONS
210210
throw new Error('runtime environment is shell, but not compiled with support for that');
211211
#endif // ASSERTIONS
212+
} else
212213
#endif // ENVIRONMENT_MAY_BE_SHELL
213-
}
214-
else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
215214
#if ENVIRONMENT_MAY_BE_WEB_OR_WORKER
215+
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
216216
Module['read'] = function shell_read(url) {
217217
#if SUPPORT_BASE64_EMBEDDING
218218
try {
@@ -281,14 +281,13 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
281281
#if ASSERTIONS
282282
throw new Error('runtime environment is web or worker, but not compiled with support for that');
283283
#endif // ASSERTIONS
284+
} else
284285
#endif // ENVIRONMENT_MAY_BE_WEB_OR_WORKER
285-
}
286+
{
286287
#if ASSERTIONS
287-
else {
288-
// Unreachable because SHELL is dependent on the others
289288
throw new Error('unknown runtime environment');
290-
}
291289
#endif // ASSERTIONS
290+
}
292291

293292
// console.log is checked first, as 'print' on the web will open a print dialogue
294293
// printErr is preferable to console.warn (works better in shells)

0 commit comments

Comments
 (0)