Read named capture groups by name
This commit is contained in:
@@ -6,8 +6,8 @@ import { isNotFound } from "#common";
|
|||||||
import type { RuntimeProfile } from "#runtime";
|
import type { RuntimeProfile } from "#runtime";
|
||||||
|
|
||||||
export function isRunnableProfileProcess(status: string, uid: number): boolean {
|
export function isRunnableProfileProcess(status: string, uid: number): boolean {
|
||||||
const owner = /^Uid:\s+(?<uid>\d+)/mu.exec(status)?.[1];
|
const owner = /^Uid:\s+(?<uid>\d+)/mu.exec(status)?.groups?.["uid"];
|
||||||
const state = /^State:\s+(?<state>\w)/mu.exec(status)?.[1];
|
const state = /^State:\s+(?<state>\w)/mu.exec(status)?.groups?.["state"];
|
||||||
return owner !== undefined && Number(owner) === uid && state !== "Z";
|
return owner !== undefined && Number(owner) === uid && state !== "Z";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -211,10 +211,11 @@ async function renderPrompt(profile: RuntimeProfile): Promise<RenderedPrompt> {
|
|||||||
]);
|
]);
|
||||||
const template = await readFile(new URL("../../prompt.md", import.meta.url), "utf8");
|
const template = await readFile(new URL("../../prompt.md", import.meta.url), "utf8");
|
||||||
return {
|
return {
|
||||||
prompt: template.replaceAll(
|
prompt: template.replaceAll(/\$\{(?<name>\w+)\}/gu, (match: string, ...args: unknown[]) => {
|
||||||
/\$\{(?<name>\w+)\}/gu,
|
const groups = args.at(-1);
|
||||||
(match: string, name: string) => values.get(name) ?? match,
|
const name = isObject(groups) ? field(groups, "name") : undefined;
|
||||||
),
|
return typeof name === "string" ? (values.get(name) ?? match) : match;
|
||||||
|
}),
|
||||||
reviewPath,
|
reviewPath,
|
||||||
anchorsPath,
|
anchorsPath,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user