26 lines
669 B
Bash
Executable File
26 lines
669 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
node --input-type=module - "$1" <<'NODE'
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const messagePath = process.argv[2];
|
|
const message = readFileSync(messagePath, 'utf8');
|
|
const subject = message
|
|
.split(/\r?\n/)
|
|
.find((line) => line.trim() && !line.trimStart().startsWith('#'))
|
|
?.trim();
|
|
|
|
if (!subject) {
|
|
console.error('commit-msg: commit subject is empty.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const startsWithEmoji = /^(?:\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F?)/u.test(subject);
|
|
|
|
if (!startsWithEmoji) {
|
|
console.error('commit-msg: commit subject must start with an emoji, for example "✨ add asset cache".');
|
|
process.exit(1);
|
|
}
|
|
NODE
|