mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-01 06:23:28 +08:00
fix: accept crlf command frontmatter
This commit is contained in:
committed by
Affaan Mustafa
parent
01d3743a8c
commit
70cc2bb247
@@ -29,20 +29,17 @@ function getCommandFiles() {
|
||||
}
|
||||
|
||||
function parseFrontmatter(content) {
|
||||
if (!content.startsWith('---\n')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const endIndex = content.indexOf('\n---', 4);
|
||||
if (endIndex === -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return content.slice(4, endIndex);
|
||||
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
console.log('\n=== Testing command frontmatter metadata ===\n');
|
||||
|
||||
test('frontmatter parser accepts LF and CRLF line endings', () => {
|
||||
assert.strictEqual(parseFrontmatter('---\ndescription: ok\n---\n# Title'), 'description: ok');
|
||||
assert.strictEqual(parseFrontmatter('---\r\ndescription: ok\r\n---\r\n# Title'), 'description: ok');
|
||||
});
|
||||
|
||||
for (const fileName of getCommandFiles()) {
|
||||
test(`${fileName} declares command metadata frontmatter`, () => {
|
||||
const content = fs.readFileSync(path.join(commandsDir, fileName), 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user