Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ added:
-->

* `path` {string}
* Returns: {module.SourceMap}
* Returns: {module.SourceMap|undefined} Returns `module.SourceMap` if a source
map is found, `undefined` otherwise.

`path` is the resolved path for the file for which a corresponding source map
should be fetched.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/source_map/prepare_stack_trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function getOriginalSource(payload, originalSourcePath) {

function getSourceMapErrorSource(fileName, lineNumber, columnNumber) {
const sm = findSourceMap(fileName);
if (sm === null) {
if (sm === undefined) {
return;
}
const {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/source_map/source_map_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function findSourceMap(sourceURL) {
if (sourceMap && sourceMap.data) {
return new SourceMap(sourceMap.data);
}
return null;
return undefined;
}

module.exports = {
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-source-map-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ const { readFileSync } = require('fs');
);
}

// `findSourceMap()` should return undefined when no source map is found.
{
const files = [
__filename,
'',
'invalid-file',
];
for (const file of files) {
const sourceMap = findSourceMap(file);
assert.strictEqual(sourceMap, undefined);
}
}

// findSourceMap() can lookup source-maps based on URIs, in the
// non-exceptional case.
{
Expand Down