|
| 1 | +import { existsSync, readFileSync } from 'node:fs'; |
| 2 | +import { fileURLToPath } from 'node:url'; |
| 3 | +import { describe, expect, it } from 'vitest'; |
| 4 | + |
| 5 | +const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)); |
| 6 | + |
| 7 | +function readRepoFile(relativePath: string): string { |
| 8 | + return readFileSync(`${repoRoot}${relativePath}`, 'utf8'); |
| 9 | +} |
| 10 | + |
| 11 | +describe('repository standard docs', () => { |
| 12 | + it('keeps root pointers to the canonical GitHub standard docs', () => { |
| 13 | + const pointers = [ |
| 14 | + { |
| 15 | + rootPath: 'CODE_OF_CONDUCT.md', |
| 16 | + githubPath: '.github/CODE_OF_CONDUCT.md', |
| 17 | + heading: 'Code of Conduct', |
| 18 | + }, |
| 19 | + { |
| 20 | + rootPath: 'CONTRIBUTING.md', |
| 21 | + githubPath: '.github/CONTRIBUTING.md', |
| 22 | + heading: 'Contributing', |
| 23 | + }, |
| 24 | + { |
| 25 | + rootPath: 'SECURITY.md', |
| 26 | + githubPath: '.github/SECURITY.md', |
| 27 | + heading: 'Security', |
| 28 | + }, |
| 29 | + ]; |
| 30 | + |
| 31 | + for (const pointer of pointers) { |
| 32 | + expect(existsSync(`${repoRoot}${pointer.rootPath}`)).toBe(true); |
| 33 | + expect(existsSync(`${repoRoot}${pointer.githubPath}`)).toBe(true); |
| 34 | + const rootPointer = readRepoFile(pointer.rootPath); |
| 35 | + expect(rootPointer).toContain(`[${pointer.githubPath}](${pointer.githubPath})`); |
| 36 | + expect(rootPointer).toContain(`# ${pointer.heading}\n\n`); |
| 37 | + } |
| 38 | + }); |
| 39 | +}); |
0 commit comments