Optimized the root .gitignore to exclude virtual environments, node modules, and temp folders to ensure clean and lightweight version tracking. Co-authored-by: Cursor <cursoragent@cursor.com>
18 lines
410 B
TypeScript
18 lines
410 B
TypeScript
import fs from 'fs';
|
|
|
|
/**
|
|
* 从文件注释中读取显示名称
|
|
*/
|
|
export function getDisplayName(filePath: string): string | null {
|
|
try {
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
const nameMatch = content.match(/@(?:name|displayName)\s+(.+)/);
|
|
if (nameMatch && nameMatch[1]) {
|
|
return nameMatch[1].trim();
|
|
}
|
|
} catch (err) {
|
|
// 忽略读取错误
|
|
}
|
|
return null;
|
|
}
|