@cspotcode/source-map-support
Advanced tools
Comparing version 0.6.0-0 to 0.6.0-1
{ | ||
"name": "@cspotcode/source-map-support", | ||
"description": "Fixes stack traces for files with source maps", | ||
"version": "0.6.0-0", | ||
"version": "0.6.0-1", | ||
"main": "./source-map-support.js", | ||
"types": "./source-map-support.d.ts", | ||
"scripts": { | ||
@@ -12,4 +13,6 @@ "build": "node build.js", | ||
"files": [ | ||
"source-map-support.js", | ||
"register.js" | ||
"/register.d.ts", | ||
"/register.js", | ||
"/source-map-support.d.ts", | ||
"/source-map-support.js" | ||
], | ||
@@ -16,0 +19,0 @@ "dependencies": { |
var SourceMapConsumer = require('@cspotcode/source-map-consumer').SourceMapConsumer; | ||
var path = require('path'); | ||
var util = require('util'); | ||
@@ -301,2 +302,13 @@ var fs; | ||
var line = ""; | ||
var isAsync = this.isAsync ? this.isAsync() : false; | ||
if(isAsync) { | ||
line += 'async '; | ||
var isPromiseAll = this.isPromiseAll ? this.isPromiseAll() : false; | ||
var isPromiseAny = this.isPromiseAny ? this.isPromiseAny() : false; | ||
if(isPromiseAny || isPromiseAll) { | ||
line += isPromiseAll ? 'Promise.all (index ' : 'Promise.any (index '; | ||
var promiseIndex = this.getPromiseIndex(); | ||
line += promiseIndex + ')'; | ||
} | ||
} | ||
var functionName = this.getFunctionName(); | ||
@@ -489,3 +501,3 @@ var addSuffix = true; | ||
function printErrorAndExit (error) { | ||
function printFatalErrorUponExit (error) { | ||
var source = getErrorSource(error); | ||
@@ -502,4 +514,9 @@ | ||
console.error(error); | ||
process.exit(1); | ||
// Matches node's behavior for colorized output | ||
console.error( | ||
util.inspect(error, { | ||
customInspect: false, | ||
colors: process.stderr.isTTY | ||
}) | ||
); | ||
} | ||
@@ -509,14 +526,16 @@ | ||
var origEmit = process.emit; | ||
var isTerminatingDueToFatalException = false; | ||
var fatalException; | ||
process.emit = function (type) { | ||
if (type === 'uncaughtException') { | ||
var hasStack = (arguments[1] && arguments[1].stack); | ||
var hasListeners = (this.listeners(type).length > 0); | ||
if (hasStack && !hasListeners) { | ||
return printErrorAndExit(arguments[1]); | ||
} | ||
const hadListeners = origEmit.apply(this, arguments); | ||
if (type === 'uncaughtException' && !hadListeners) { | ||
isTerminatingDueToFatalException = true; | ||
fatalException = arguments[1]; | ||
process.exit(1); | ||
} | ||
return origEmit.apply(this, arguments); | ||
if (type === 'exit' && isTerminatingDueToFatalException) { | ||
printFatalErrorUponExit(fatalException); | ||
} | ||
return hadListeners; | ||
}; | ||
@@ -523,0 +542,0 @@ } |
35480
7
621