Fix source map utils

Reviewed By: javache

Differential Revision: D3302496

fbshipit-source-id: de15a289497119c7f600b8796452fc9573ea7394
This commit is contained in:
Spencer Ahrens 2016-05-14 10:34:23 -07:00 committed by Facebook Github Bot 3
parent 3a2d024514
commit c2a8e52d72
1 changed files with 18 additions and 19 deletions

View File

@ -12,15 +12,15 @@
'use strict';
var Promise = require('Promise');
var NativeModules = require('NativeModules');
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
var SourceMapURL = require('./source-map-url');
const Promise = require('Promise');
const NativeModules = require('NativeModules');
const SourceMapConsumer = require('SourceMap').SourceMapConsumer;
const SourceMapURL = require('./source-map-url');
var RCTSourceCode = NativeModules.SourceCode;
var RCTNetworking = NativeModules.Networking;
const RCTSourceCode = NativeModules.SourceCode;
const RCTNetworking = NativeModules.Networking;
var SourceMapsUtils = {
const SourceMapsUtils = {
fetchMainSourceMap(): Promise {
return SourceMapsUtils._getMainSourceMapURL().then(url =>
SourceMapsUtils.fetchSourceMap(url)
@ -40,14 +40,14 @@ var SourceMapsUtils = {
if (fullSourceMappingURL) {
return fullSourceMappingURL;
}
var mapURL = SourceMapURL.getFrom(text);
const mapURL = SourceMapURL.getFrom(text);
if (!mapURL) {
return null;
}
if (!url) {
return null;
}
var baseURLs = url.match(/(.+:\/\/.*?)\//);
const baseURLs = url.match(/(.+:\/\/.*?)\//);
if (!baseURLs || baseURLs.length < 2) {
return null;
}
@ -70,16 +70,15 @@ var SourceMapsUtils = {
const scriptText = RCTSourceCode.getScriptText();
if (scriptText) {
scriptText
.then(SourceMapsUtils.extractSourceMapURL)
.then((url) => {
if (url === null) {
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
}
return Promise.resolve(url);
});
}
else {
return scriptText
.then(SourceMapsUtils.extractSourceMapURL)
.then((url) => {
if (url === null) {
return Promise.reject(new Error('No source map URL found. May be running from bundled file.'));
}
return Promise.resolve(url);
});
} else {
// Running in mock-config mode
return Promise.reject(new Error('Couldn\'t fetch script text'));
}