marko/compiler/util/PosInfo.js
2015-12-02 19:35:19 -07:00

26 lines
577 B
JavaScript

'use strict';
var path = require('path');
function getRelativePath(absolutePath) {
if (typeof window === 'undefined') {
absolutePath = path.resolve(process.cwd(), absolutePath);
return path.relative(process.cwd(), absolutePath);
} else {
return absolutePath;
}
}
class PosInfo {
constructor(path, line, column) {
this.path = getRelativePath(path);
this.line = line;
this.column = column;
}
toString() {
return this.path + ":" + this.line + ":" + this.column;
}
}
module.exports = PosInfo;