Skip to content

This tool should you control the scope of diff changes

License

Notifications You must be signed in to change notification settings

AlekseyLeshko/lines-control

Repository files navigation

lines-control

This tool should you control the scope of diff changes

Install

$ npm i lines-control -D
or
$ yarn add lines-control -D

Usage

Terminal example

You can use this module in your terminal.

$ lines-control --rules total,50

You can apply a rule for filtered files. It uses the minimatch library to do its matching.

$ lines-control --rules total,50,src/**/*
$ lines-control --rules total,50,src/**/* totalInsertions,5,webpack/**/*

You can compare the two branches.

$ lines-control --rules total,50,src/**/* --comparisons origin/main
$ lines-control --rules total,50,src/**/* --comparisons origin/main,/feature-x
$ lines-control --rules total,50,src/**/* --comparisons origin/feature-x,origin/feature-y

and combine it

$ lines-control
  --rules total,50,src/**/* totalInsertions,5,webpack/**/*
  --comparisons origin/feature-x,origin/feature-y

lint-staged example

You can check how many lines have been touched each time you create a commit.

{
  "lint-staged": {
    "*": "lines-control --rules total,50,src/**/*"
  }
}

husky and lint-staged example

You can check how many lines have been touched each time you create a commit.

//
{
  "lint-staged": {
    "*": "lines-control --rules total,50,src/**/*"
  }
}

CI:github actions example

You can create a CI step like

  lines-control:
    runs-on: ubuntu-latest

    steps:
      - name: Load current commit
        uses: actions/checkout@v2
        with:
          ref: ${{ github.ref }}

     ...

      - name: Lines control
        run: yarn lines-control --rules totalInsertions,50 --comparisons origin/main

CLI help

$ npx lines-control -h

Usage: lines-control [options]

Options:
  -r, --rules <value...>     Rules for checking.
                             Types: total, totalInsertions;
                             example: total;50;src/**/* (default: [])
  -c, --comparisons <value>  Comparison of commits and branches
  -v, --vers                 output the current version
  -h, --help                 display help for command

  Example call:
    $ lines-control --rules total,25 totalInsertions,5,src/**/*
    $ lines-control --rules total,25 --comparisons master,feature/test-branch-name
    $ lines-control --rules total,25 --comparisons main

About

This tool should you control the scope of diff changes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published