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