Prevent "oops" moments by running preflight checks before every Git push
A lightweight, configurable Git pre-push hook that automatically runs your quality checks (tests, linting, type-checking, etc.) before allowing a push to go through.
- Zero Configuration - Works out of the box with sensible defaults
- Highly Configurable - Customize commands, messages, and behavior
- Auto-Installation - Automatically sets up Git hooks on install
- Beautiful Output - Color-coded, clean terminal output
- Timeout Support - Prevent hung processes
- Branch-Specific - Skip checks on specific branches
- CI-Aware - Automatically skips in CI environments
- TypeScript Support - Fully typed for better DX
npm install --save-dev no-push-oopsOr with yarn:
yarn add -D no-push-oopsOr with pnpm:
pnpm add -D no-push-oopsIf the hook isn't installed automatically:
npx no-push-oops install- Install the package:
npm install --save-dev no-push-oops- Add configuration to your
package.json:
{
"no-push-oops": {
"command": "npm run pr-preflight"
},
"scripts": {
"pr-preflight": "npm run lint && npm run test && npm run build"
}
}- That's it! Now every time you push, your preflight checks will run automatically.
You can configure no-push-oops in three ways:
- In
package.json:
{
"no-push-oops": {
"command": "npm run pr-preflight",
"message": "Running quality checks...",
"skipCI": true,
"skipOnBranches": ["main", "develop"],
"verbose": false,
"timeout": 300000
}
}- In
.nopushoopsrc.json:
{
"command": "npm run pr-preflight",
"message": "Running quality checks...",
"skipCI": true
}- In
.nopushoopsrc:
{
"command": "npm run pr-preflight"
}| Option | Type | Default | Description |
|---|---|---|---|
command |
string |
"npm run pr-preflight" |
Single command to run |
commands |
string[] |
- | Multiple commands to run in sequence |
message |
string |
"Running pr-preflight checks before push" |
Custom message to display |
skipCI |
boolean |
true |
Skip checks in CI environments |
skipOnBranches |
string[] |
[] |
Branches to skip checks on |
verbose |
boolean |
false |
Show detailed output |
timeout |
number |
300000 |
Command timeout in milliseconds |
You can run multiple commands in sequence:
{
"no-push-oops": {
"commands": ["npm run lint", "npm run test", "npm run type-check", "npm run build"]
}
}Once installed, no-push-oops will automatically run on every git push. If the checks fail, the push will be aborted.
You can manually run the checks:
npx no-push-oops runIf you need to bypass the hook (not recommended):
git push --no-verifyTo remove the hook:
npx no-push-oops uninstall{
"no-push-oops": {
"command": "npm run lint && npm run test"
}
}{
"no-push-oops": {
"commands": [
"npm run lint",
"npm run test:unit",
"npm run test:integration",
"npm run type-check",
"npm run build"
],
"message": "Running full CI pipeline...",
"timeout": 600000
}
}{
"no-push-oops": {
"command": "npm run validate",
"skipOnBranches": ["main", "master", "production"]
}
}{
"no-push-oops": {
"command": "npm run test",
"verbose": true
}
}# Install the pre-push hook
npx no-push-oops install
# Uninstall the pre-push hook
npx no-push-oops uninstall
# Run checks manually
npx no-push-oops run
# Show help
npx no-push-oops helpProblem: You push code, CI fails, you fix it, push again, repeat...
Solution: Run your CI checks locally before pushing. Catch issues early!
- Catch issues before pushing - Save time and embarrassment
- Faster feedback - Know immediately if something's wrong
- Better Git history - No "fix CI" commits
- Team consistency - Everyone runs the same checks
- Easy to set up - One npm install and you're done
| Feature | no-push-oops | husky | pre-commit |
|---|---|---|---|
| Zero config | Yes | No | No |
| TypeScript | Yes | No | No |
| Pre-push focus | Yes | No | No |
| Auto-install | Yes | Yes | Yes |
| Branch filtering | Yes | No | Yes |
| Timeout support | Yes | No | Yes |
Check out these example configurations:
{
"scripts": {
"pr-preflight": "npm run lint && npm run type-check && npm run test && npm run build"
},
"no-push-oops": {
"command": "npm run pr-preflight",
"skipOnBranches": ["main"]
}
}{
"scripts": {
"pr-preflight": "npm run lint && npm run test:coverage && npm run build"
},
"no-push-oops": {
"commands": [
"npm run lint",
"npm run test:coverage",
"npm run security-check",
"npm run build"
],
"timeout": 600000
}
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT © Sheikh
A: Use git push --no-verify to bypass the hook. But use this sparingly!
A: Not directly, but you can skip checks on certain branches and implement branch logic in your scripts.
A: Yes! It works with any Git repository.
A: Run npx no-push-oops install manually to reinstall the hook.
A: Yes! Install it at the root and configure commands accordingly.
Made to prevent oops moments