@@ -38,10 +38,10 @@ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIR
38
38
if ( ENVIRONMENT_IS_NODE ) {
39
39
// Expose functionality in the same simple way that the shells work
40
40
// Note that we pollute the global namespace here, otherwise we break in node
41
- Module [ 'print' ] = function print ( x ) {
41
+ if ( ! Module [ 'print' ] ) Module [ 'print' ] = function print ( x ) {
42
42
process [ 'stdout' ] . write ( x + '\n' ) ;
43
43
} ;
44
- Module [ 'printErr' ] = function printErr ( x ) {
44
+ if ( ! Module [ 'printErr' ] ) Module [ 'printErr' ] = function printErr ( x ) {
45
45
process [ 'stderr' ] . write ( x + '\n' ) ;
46
46
} ;
47
47
@@ -71,7 +71,7 @@ if (ENVIRONMENT_IS_NODE) {
71
71
module [ 'exports' ] = Module ;
72
72
}
73
73
else if ( ENVIRONMENT_IS_SHELL ) {
74
- Module [ 'print' ] = print ;
74
+ if ( ! Module [ 'print' ] ) Module [ 'print' ] = print ;
75
75
if ( typeof printErr != 'undefined' ) Module [ 'printErr' ] = printErr ; // not present in v8 or older sm
76
76
77
77
if ( typeof read != 'undefined' ) {
@@ -107,16 +107,16 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
107
107
}
108
108
109
109
if ( typeof console !== 'undefined' ) {
110
- Module [ 'print' ] = function print ( x ) {
110
+ if ( ! Module [ 'print' ] ) Module [ 'print' ] = function print ( x ) {
111
111
console . log ( x ) ;
112
112
} ;
113
- Module [ 'printErr' ] = function printErr ( x ) {
113
+ if ( ! Module [ 'printErr' ] ) Module [ 'printErr' ] = function printErr ( x ) {
114
114
console . log ( x ) ;
115
115
} ;
116
116
} else {
117
117
// Probably a worker, and without console.log. We can do very little here...
118
118
var TRY_USE_DUMP = false ;
119
- Module [ 'print' ] = ( TRY_USE_DUMP && ( typeof ( dump ) !== "undefined" ) ? ( function ( x ) {
119
+ if ( ! Module [ 'print' ] ) Module [ 'print' ] = ( TRY_USE_DUMP && ( typeof ( dump ) !== "undefined" ) ? ( function ( x ) {
120
120
dump ( x ) ;
121
121
} ) : ( function ( x ) {
122
122
// self.postMessage(x); // enable this if you want stdout to be sent as messages
0 commit comments