1.0.4 • Published 4 years ago

git-branch-check v1.0.4

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

git-branch-check

用于检查当前git分支是否满足执行命令的条件,用在npm script hook上,防止在错误的分支执行了错误的命令

安装

npm install git-branch-check -D

yarn add git-branch-check -D

使用

//package.json
{
  "name": "xxx",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "node ./build.js",
    "prebuild": "npx git-branch-check include master",
    "staging": "node ./staging.js",
    "prestaging": "npx git-branch-check exclude master"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "colors": "^1.4.0",
    "commander": "^6.0.0",
    "execa": "^4.0.3"
  }
}

如上配置,npm run build 只能在master分支运行,其他分支运行则会报错,而npm run staging 则是只能在master分支之外的分支执行,master分支执行则会报错

说明

Usage: git-branch-check [options] [command]

Options:
  -V, --version       output the version number
  -h, --help          display help for command

Commands:
  include <branches>  允许在限制的分支中执行,多个分支以","符号分割
  exclude <branches>  允许在排除的分支中执行,多个分支以","符号分割
  help [command]      display help for command
1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

10 years ago