Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lint-staged

#!/bin/sh

# Husky pre-commit hook to update companion/HELP.md with all action names and descriptions
node scripts/update-actions-md.js
git add companion/HELP.md
3 changes: 3 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

node scripts/check-tag.js
42 changes: 42 additions & 0 deletions scripts/check-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { execSync } from 'child_process'
import * as fs from 'fs'

function run(cmd) {
try {
return execSync(cmd, { stdio: ['ignore', 'pipe', 'ignore'] })
.toString()
.trim()
} catch {
return null
}
}

if (!fs.existsSync('package.json')) {
throw new Error('package.json not found')
}

const tag = run('git describe --tags --abbrev=0')

if (!tag) {
throw new Error('No git tag found on this branch')
}

if (!/^v\d+(\.\d+){2,3}$/.test(tag)) {
throw new Error(`Latest tag '${tag}' does not match vX.Y.Z or vX.Y.Z.W`)
}

let pkg
try {
pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
} catch {
throw new Error('Cannot parse package.json')
}

const pkgVersion = pkg.version
const tagVersion = tag.slice(1)

if (pkgVersion !== tagVersion) {
throw new Error(`ERROR: package.json version (${pkgVersion}) does not match git tag (${tag})`)
}

console.log(`Git tag '${tag}' matches package.json version '${pkgVersion}'`)