npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-diff-script-exclusions

v3.2.2

Published

Never run your CI unnecessarily again.

Downloads

27

Readme

git-diff-script-exclusions

Never run your CI unnecessarily again.

Git-diff-script-exclusions is a CLI tool which allows to compare two git commits and see if modified files are strictly limited to excluded path that you have configured.

Can be used to determine if a complex operation like launching tests in a CI context is required regarding modified files.

How to use

This tool has to be used in a git repo.

Dependencies

  • Node (tested on v14 and v16)

Configure

Exceptions are stored in the file git-diff-script-exclusions.conf.json. It follow the format below 👇

    {
    "exceptions": [
            "docs/*",
            "git-diff-script-exclusions.conf.json"
            "src/ressource/application.yml"
        ]
    }

Paths can be folders or files.

Install and use

Install globally 👇

$: npm install -g git-diff-script-exclusions
$: npm exec git-diff-script-exclusions --source source_commit_sha --target targe_commit_sha

Or use via Npx 👇

$: npx git-diff-script-exclusions --source source_commit_sha --target targe_commit_sha

Use --help if needed.

You can use commit SHA or branch name

The CLI will return 👇

|============================================================|
| $: npx git-diff-script-exclusions -- -s my_feature -t main |
|============================================================|

INFO : Comparing : my_feature to : main

Exceptions configured :
 [ [ 'docs', '*' ], [ 'git-diff-script-exclusions.conf.json' ] ]

{
  modifiedFilesInNewestCommit: [
    [ 'git-diff-script-exclusions.conf.json' ],
    [ 'docs/my_doc.md' ]
  ],
  onlyExceptions: true
}

The tool print configured exceptions and modified files between source and target commmit. If modified files are strictly contained in the configuration, return will be onlyExceptions: true otherwise it will be onlyExceptions: false.

You can use grep to pipe git-diff-script-exclusions with other CLI tools.

Use in CI

Gitlab

stages:
  - test

test:
  stage: test
  image:
    name: node:lts
  script:
    - npm install -g git-diff-script-exclusions
    - echo 'Checking if tests need to be executed...'
    - GIT_DIFF_SCRIPT_EXCLUSIONS=$(npx git-diff-script-exclusions --source $CI_COMMIT_SHA)
    - echo $GIT_DIFF_SCRIPT_EXCLUSIONS
    - >
      if grep -q "onlyExceptions: true" <<< "$GIT_DIFF_SCRIPT_EXCLUSIONS"; then
        echo 'Tests are not required';
      else
        echo 'Launching tests...';
        npm ci
        npm test
      fi;

Github

name: Run Test

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v3
      with:
        node-version: 16
    - name: Install dependencies
      run: npm install -g git-diff-script-exclusions
    - name: Launch tests if needed
      run: |
        echo "Checking if tests need to be executed..."
        GIT_DIFF_SCRIPT_EXCLUSIONS=$(npx git-diff-script-exclusions --source $GITHUB_REF)
        echo $GIT_DIFF_SCRIPT_EXCLUSIONS
        if grep -q "onlyExceptions: true" <<< "$GIT_DIFF_SCRIPT_EXCLUSIONS"; then
          echo "Tests are not required"
        else
          echo "Launching tests..."
          npm ci
          npm test
        fi

Contribute

We welcome contributions to this project! If you have an idea for a new feature or a bug fix, please open an issue on our GitHub page before submitting a pull request. Thank you for your contribution!

To launch the project in development use this command 👇

$: npm run dev

License

git-diff-script-exclusions is available under the MIT license.