Put "file:line" when we can't resolve function name

Reviewed By: michalgr

Differential Revision: D3670558

fbshipit-source-id: 2a60babf16ac6e6be77ebb6e76f5179b024a77c6
This commit is contained in:
Lukas Piatkowski 2016-08-05 06:02:20 -07:00 committed by Facebook Github Bot
parent 53c1da0047
commit 4e3b484631
1 changed files with 4 additions and 3 deletions

View File

@ -11,6 +11,7 @@
const SourceMapConsumer = require('source-map').SourceMapConsumer;
const fs = require('fs');
const http = require('http');
const path = require('path');
const urlLib = require('url');
class TreeTransformator {
@ -31,7 +32,8 @@ class TreeTransformator {
line: tree.lineNumber,
column: tree.columnNumber,
});
tree.functionName = original.name;
tree.functionName = original.name
|| (path.posix.basename(original.source) + ':' + original.line);
tree.scriptId = tree.id;
tree.url = 'file://' + original.source;
tree.lineNumber = original.line;
@ -89,8 +91,7 @@ class TreeTransformator {
resBody += chunk;
}).on('end', () => {
sawEnd = true;
const map = JSON.parse(resBody.replace(/^\)\]\}'/, ''));
this.urlResults[url] = new SourceMapConsumer(map);
this.urlResults[url] = new SourceMapConsumer(resBody);
callback();
}).on('close', (err) => {
if (!sawEnd) {