mirror of
https://github.com/thangisme/notes.git
synced 2024-12-22 19:46:23 -05:00
21 lines
498 B
JavaScript
21 lines
498 B
JavaScript
var _ = require('lodash');
|
|
|
|
exports.getLocation = function(message) {
|
|
var messageNode = message.node;
|
|
|
|
var location = {
|
|
line: message.line,
|
|
column: message.column,
|
|
};
|
|
|
|
var messageInput = _.get(messageNode, 'source.input');
|
|
|
|
if (!messageInput) return location;
|
|
|
|
var originLocation = messageInput.origin && messageInput.origin(message.line, message.column)
|
|
if (originLocation) return originLocation
|
|
|
|
location.file = messageInput.file || messageInput.id;
|
|
return location;
|
|
};
|