Skip to content

Commit 7be65b2

Browse files
committed
adding some checks to prevent improper releases
1 parent e273008 commit 7be65b2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"check": "npm run format:check && npm run lint && npm t",
3333
"build": "npm run check && npm run bundle && npm run minify",
3434
"prepare": "npm run build",
35-
"release": "npm run clean && npm i && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
35+
"release": "./pre-flight-tests && npm run clean && npm i && git tag $npm_package_version && git push && git push --tags && npm publish"
3636
},
3737
"prettier": {
3838
"semi": false

pre-flight-tests

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
3+
// eslint-disable-next-line no-undef
4+
const { execSync } = require("child_process")
5+
const exec = command => execSync(command, { encoding: "utf8" })
6+
7+
const gitBranchName = exec("git rev-parse --abbrev-ref HEAD")
8+
if (gitBranchName.trim() !== "master") {
9+
throw new Error("please checkout the master branch to make a release!")
10+
}
11+
12+
const workingCopyChanges = exec("git status --porcelain")
13+
if (workingCopyChanges.trim() !== "") {
14+
throw new Error("please commit your changes before making a release!")
15+
}

0 commit comments

Comments
 (0)