lib: codify findSourceMap return value when not found
Return `undefined` when no source map is found for the given filename on `findSourceMap`. PR-URL: https://github.com/nodejs/node/pull/44397 Fixes: https://github.com/nodejs/node/issues/44391 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
808fe9828d
commit
72df448d2a
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -297,7 +297,7 @@ function findSourceMap(sourceURL) {
|
||||
if (sourceMap && sourceMap.data) {
|
||||
return new SourceMap(sourceMap.data);
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -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.
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user