aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-22 14:26:28 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-22 14:26:28 -0700
commit22d510338239c1cf33136392c77a9b3d7d2ce2bc (patch)
treeb2a697df7edd3cf9177a30e4de4f0940595142fc
parentb040c0d6d4896017b1af268d0c89b7575cf3b343 (diff)
fix file packager Module autocreation
-rw-r--r--tools/file_packager.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 0696e4da..142702e2 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -627,8 +627,8 @@ if has_preloaded:
'''
ret += '''
- if (typeof Module == 'undefined') Module = {};
- if (!Module['preRun']) Module['preRun'] = [];
+ var Module;
+ if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
function runWithFS() {
'''
ret += code
@@ -637,6 +637,7 @@ ret += '''
if (Module['calledRun']) {
runWithFS();
} else {
+ if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
}
'''