git-test-cli

1.1.0 • Public • Published

git-test

Simple CLI utility to test git output and return exit 1 if a test fails

Installation

npm install -g git-test-cli

Usage

[master] > git-test -b master && echo on master || echo not on master
on master

[master] > git checkout feature
[feature] > git-test -b master && echo on master || echo not on master
not on master

The intended use is as a scripting helper, e.g. to perform certain actions during automated processes (such as builds) based on the current git branch. For example, using husky, the following will run tests before pushing code to master:

{
   "scripts": {
       "prepush": "git-test -b master && npm test || git-test -x -b master"
   } 
}

The -x option inverts the result of the test, e.g. tests that the branch is not master. The negative test following the || is needed to ensure the logic following the initial test is atomic. That is, every logical test that starts with the assertion "if I'm on this branch" should end with an "or" condition of "if I'm not on this branch".

Right now it's only feature is to test which branch is active. If I need more... I will add it.

Options

--branch [branch-name]
-b [branch-name]

Test that the current git repo is on [branch-name]

--except [branch-name]
-x [branch-name]

Invert the result of every other test

--help

Show help

--status

Just output the status info I obtained from git as JSON (for diagnostics)

Readme

Keywords

none

Package Sidebar

Install

npm i git-test-cli

Weekly Downloads

11

Version

1.1.0

License

MIT

Last publish

Collaborators

  • jamietre