mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-03 12:17:03 +00:00
* fix(inspector): a component report names a snippet's file and lines only in its id * fix(inspector): drop the comment the ratchet refuses * fix(inspector): prioritize unqueried co-targets in compact reports
12 lines
449 B
TypeScript
12 lines
449 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
/** The file lines a snippet id, `<file>:<start>-<end>`, names, as they are on disk now. */
|
|
export function snippetSource(project: string, id: string): string {
|
|
const [, file, startLine, endLine] = /^(.+):(\d+)-(\d+)$/.exec(id)!;
|
|
return readFileSync(join(project, file!), "utf8")
|
|
.split(/(?<=\n)/)
|
|
.slice(Number(startLine) - 1, Number(endLine))
|
|
.join("");
|
|
}
|