@k8ts/instruments
Version:
A collection of utilities and core components for k8ts.
28 lines • 985 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Trace = void 0;
const lodash_1 = require("lodash");
const path_1 = require("path");
class Trace {
trace;
constructor(trace) {
const findGoodFrame = (e) => {
return !e.native && e.file && !e.file.includes("node:");
};
this.trace = trace.filter(x => !!findGoodFrame(x)).at(0);
}
format(inOptions) {
const e = this.trace;
const options = (0, lodash_1.defaults)(inOptions, {
cwd: ".",
absolute: false
});
options.cwd = (0, path_1.resolve)(options.cwd);
const sourcePath = options.absolute ? e.file : (0, path_1.relative)(options.cwd, e.file);
const relativeToCwd = (0, path_1.relative)(options.cwd, sourcePath);
const sourceLocation = `${relativeToCwd}:${e.line}:${e.column}`;
return sourceLocation;
}
}
exports.Trace = Trace;
//# sourceMappingURL=trace.js.map