Merge pull request #79 from LinusU/patch-3

Better check for `process.on()`.
This commit is contained in:
Julien Fontanet 2015-06-22 11:12:59 +02:00
commit 1e448d62fc

View File

@ -21,6 +21,10 @@ function isInBrowser() {
return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function')); return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function'));
} }
function hasGlobalProcessEventEmitter() {
return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function'));
}
function retrieveFile(path) { function retrieveFile(path) {
// Trim the path to make sure there is no extra whitespace. // Trim the path to make sure there is no extra whitespace.
path = path.trim(); path = path.trim();
@ -418,7 +422,7 @@ exports.install = function(options) {
// exception handler and the process will still be terminated. However, the // exception handler and the process will still be terminated. However, the
// generated JavaScript code will be shown above the stack trace instead of // generated JavaScript code will be shown above the stack trace instead of
// the original source code. // the original source code.
if (installHandler && !isInBrowser()) { if (installHandler && hasGlobalProcessEventEmitter()) {
shimEmitUncaughtException(); shimEmitUncaughtException();
} }
} }