Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto
Something went wrong. Try again.
1.3 kB · 38 lines
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839import { execFileSync } from 'node:child_process'import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterAll, describe, expect, it } from 'vitest'
const script = join(import.meta.dirname, 'lint-commit-msg.mjs')const dir = mkdtempSync(join(tmpdir(), 'commit-lint-'))afterAll(() => rmSync(dir, { recursive: true, force: true }))
function run(message) { const msgFile = join(dir, 'msg') writeFileSync(msgFile, message) execFileSync(process.execPath, [script, msgFile])}
describe('lint-commit-msg.mjs', () => { it('accepts Conventional Commit headers', () => { run('feat: add a thing\n') run('fix(popup)!: change the close behavior\n') })
it('accepts messages git writes for us', () => { run("Merge branch 'claude/thing'\n") run('fixup! feat: add a thing\n') })
it('rejects a non-conventional header', () => { expect(() => run('added some stuff\n')).toThrow() })
it('ignores comments and everything below the scissors line', () => { run( '# please enter the commit message\nfix: close the leak\n\n' + '# ------------------------ >8 ------------------------\nnot a header, just the diff\n', ) })})