Skip to content
Open
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
24 changes: 20 additions & 4 deletions src/sourcemaps/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ class Scanner {
}

extractMapPath(file) {
// check sourceMappingURL to see if a map is defined
const mapPath = this.parseMapPath(file.filePathName);

if(mapPath) {
if (mapPath) {
output.status('', mapPath);
file.mapPathName = mapPath;
file.sourceMappingURL = true;
file.mappedFile = path.join(this.targetPath, mapPath);
return;
}

} else {
output.warn('', 'map not found');
// check to see if the file exists locally
const localPath = this.localMapPath(file.filePathName);
if (localPath) {
output.status('', localPath);
file.mapPathName = localPath;
file.sourceMappingURL = false;
file.mappedFile = path.join(this.targetPath, localPath);
return;
}

output.warn('', 'map not found');
}

async loadMapData(file) {
Expand Down Expand Up @@ -190,6 +200,12 @@ class Scanner {
}
}
}

localMapPath(sourcePath) {
const mapPath = sourcePath + '.map';
const stat = fs.statSync(mapPath, { throwIfNoEntry: false });
return stat && stat.isFile() ? path.basename(mapPath) : undefined;
}
}

module.exports = Scanner;