1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/script/prevent-pushes-to-main.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

26 lines
775 B
JavaScript

#!/usr/bin/env node
import { execSync } from 'child_process'
// [start-readme]
// This script is intended to be used as a git "prepush" hook.
// If the current branch is main, it will exit unsuccessfully and prevent the push.
// [end-readme]
const productionBranch = 'main'
const currentBranch = execSync('git symbolic-ref --short HEAD', { encoding: 'utf8' }).trim()
if (currentBranch === productionBranch) {
console.error('')
console.error(
`🤚 Whoa! Pushing to the ${productionBranch} branch has been disabled to prevent accidental deployments to production.`
)
console.error('')
console.error(
"If you're aware of the risks and really want to push to this branch, add --no-verify to bypass this check."
)
console.error('')
process.exit(1)
}