git-branch-check

1.0.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i git-branch-check

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

3.73 kB

Total Files

4

Last publish

Collaborators

  • thesadboy