(ctx: {
defaultValue: ReadonlyArray<string>;
header: OutputHeader;
project: IProject;
})
| 6 | * Converts an {@link OutputHeader} value to a string prefix for file content. |
| 7 | */ |
| 8 | export function outputHeaderToPrefix(ctx: { |
| 9 | defaultValue: ReadonlyArray<string>; |
| 10 | header: OutputHeader; |
| 11 | project: IProject; |
| 12 | }): string { |
| 13 | const { defaultValue, header, project } = ctx; |
| 14 | let lines = typeof header === 'function' ? header({ defaultValue, project }) : header; |
| 15 | if (lines === undefined) lines = defaultValue; |
| 16 | if (lines === null) return ''; |
| 17 | lines = |
| 18 | typeof lines === 'string' ? lines.split(/\r?\n/) : lines.flatMap((line) => line.split(/\r?\n/)); |
| 19 | const content = lines.join('\n'); |
| 20 | return content ? `${content}\n\n` : ''; |
| 21 | } |
no test coverage detected