refactor(okr): begge hooks bruker delt frontmatter-modul (SC2) [skip-docs]
This commit is contained in:
parent
d9f2848d90
commit
9b85c0b436
3 changed files with 116 additions and 17 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { readFileSync, existsSync, readdirSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { parseFrontmatter } from '../../lib/frontmatter.mjs';
|
||||
|
||||
const cwd = process.cwd();
|
||||
const configPath = join(cwd, '.claude', 'okr.local.md');
|
||||
|
|
@ -17,14 +18,8 @@ if (!existsSync(configPath)) {
|
|||
|
||||
try {
|
||||
const content = readFileSync(configPath, 'utf8');
|
||||
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
||||
if (!match) process.exit(0);
|
||||
|
||||
const fm = match[1];
|
||||
const get = (key) => {
|
||||
const m = fm.match(new RegExp(`${key}:\\s*["']?([^"'\\n]+)["']?`));
|
||||
return m ? m[1].trim() : null;
|
||||
};
|
||||
const { raw, get } = parseFrontmatter(content);
|
||||
if (raw === null) process.exit(0);
|
||||
|
||||
const cycleId = get('id');
|
||||
const fase = get('fase');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue