aboutsummaryrefslogtreecommitdiff
path: root/node_modules/source-map-resolve/source-map-resolve.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/source-map-resolve/source-map-resolve.js')
-rw-r--r--node_modules/source-map-resolve/source-map-resolve.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/node_modules/source-map-resolve/source-map-resolve.js b/node_modules/source-map-resolve/source-map-resolve.js
index 9979db2e5..387fc1970 100644
--- a/node_modules/source-map-resolve/source-map-resolve.js
+++ b/node_modules/source-map-resolve/source-map-resolve.js
@@ -1,4 +1,4 @@
-// Copyright 2014, 2015, 2016 Simon Lydell
+// Copyright 2014, 2015, 2016, 2017 Simon Lydell
// X11 (“MIT”) Licensed. (See LICENSE.)
// Note: source-map-resolve.js is generated from source-map-resolve-node.js and
@@ -31,8 +31,9 @@ void (function(root, factory) {
}
function readSync(read, url, data) {
+ var readUrl = url
try {
- return String(read(url))
+ return String(read(readUrl))
} catch (error) {
error.sourceMapData = data
throw error
@@ -51,7 +52,8 @@ void (function(root, factory) {
if (!mapData || mapData.map) {
return callbackAsync(callback, null, mapData)
}
- read(mapData.url, function(error, result) {
+ var readUrl = mapData.url
+ read(readUrl, function(error, result) {
if (error) {
error.sourceMapData = mapData
return callback(error)
@@ -124,12 +126,17 @@ void (function(root, factory) {
callback = options
options = {}
}
- var pending = map.sources.length
+ var pending = map.sources ? map.sources.length : 0
var result = {
sourcesResolved: [],
sourcesContent: []
}
+ if (pending === 0) {
+ callbackAsync(callback, null, result)
+ return
+ }
+
var done = function() {
pending--
if (pending === 0) {
@@ -143,7 +150,8 @@ void (function(root, factory) {
result.sourcesContent[index] = sourceContent
callbackAsync(done, null)
} else {
- read(fullUrl, function(error, source) {
+ var readUrl = fullUrl
+ read(readUrl, function(error, source) {
result.sourcesContent[index] = error ? error : String(source)
done()
})
@@ -156,20 +164,27 @@ void (function(root, factory) {
sourcesResolved: [],
sourcesContent: []
}
+
+ if (!map.sources || map.sources.length === 0) {
+ return result
+ }
+
resolveSourcesHelper(map, mapUrl, options, function(fullUrl, sourceContent, index) {
result.sourcesResolved[index] = fullUrl
if (read !== null) {
if (typeof sourceContent === "string") {
result.sourcesContent[index] = sourceContent
} else {
+ var readUrl = fullUrl
try {
- result.sourcesContent[index] = String(read(fullUrl))
+ result.sourcesContent[index] = String(read(readUrl))
} catch (error) {
result.sourcesContent[index] = error
}
}
}
})
+
return result
}
@@ -217,7 +232,8 @@ void (function(root, factory) {
sourcesRelativeTo: mapUrl,
map: null
}
- read(mapUrl, function(error, result) {
+ var readUrl = mapUrl
+ read(readUrl, function(error, result) {
if (error) {
error.sourceMapData = data
return callback(error)