{"id":16374814,"url":"https://github.com/jameslnewell/run-if-diff","last_synced_at":"2025-06-27T05:33:51.409Z","repository":{"id":40799203,"uuid":"157841058","full_name":"jameslnewell/run-if-diff","owner":"jameslnewell","description":"Run a command if files have changed.","archived":false,"fork":false,"pushed_at":"2023-01-06T01:58:26.000Z","size":873,"stargazers_count":3,"open_issues_count":15,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-22T10:58:12.058Z","etag":null,"topics":["cli","diff","exec","git","run","since"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jameslnewell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-16T09:05:48.000Z","updated_at":"2021-02-05T18:38:22.000Z","dependencies_parsed_at":"2023-02-05T02:16:01.481Z","dependency_job_id":null,"html_url":"https://github.com/jameslnewell/run-if-diff","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jameslnewell/run-if-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jameslnewell%2Frun-if-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jameslnewell%2Frun-if-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jameslnewell%2Frun-if-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jameslnewell%2Frun-if-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jameslnewell","download_url":"https://codeload.github.com/jameslnewell/run-if-diff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jameslnewell%2Frun-if-diff/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261712335,"owners_count":23198183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","diff","exec","git","run","since"],"created_at":"2024-10-11T03:18:28.523Z","updated_at":"2025-06-27T05:33:51.388Z","avatar_url":"https://github.com/jameslnewell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# run-if-diff\n\n[![run-if-diff](https://img.shields.io/npm/v/run-if-diff.svg)](https://www.npmjs.com/package/run-if-diff)\n![run-if-diff](https://github.com/jameslnewell/run-if-diff/workflows/Package/badge.svg)\n\nRun a command if files are different.\n\n## Installation\n\n```bash\n# npm\nnpm i -S run-if-diff\n\n# yarn\nyarn add --dev run-if-diff\n```\n\n## Usage\n\n### `exit-if-diff`\n\nExit with an exit code of `128` if matching files have changed, Exit with an exit code of `0` if no matching files have changed.\n\n```bash\nexit-if-diff [--since \u003cref\u003e] [--file-path \u003cglob\u003e] [--file-status\n\u003cstatus\u003e] [--exit-code-when-changed \u003cnumber\u003e] [--exit-code-when-unchanged \u003cnumber\u003e]\n```\n\nExample:\n\n```bash\nset +e\nexit-if-diff --since v1.3.1 --file-path my-app.yml\nset -e\nif [ $? -eq 128 ]\n  aws cfn deploy --stack-name my-app --template-file my-app.yml\nfi\n```\n\n### `list-if-diff`\n\nList matching files that have changed.\n\n```bash\nlist-if-diff [--since \u003cref\u003e] [--file-path \u003cglob\u003e] [--file-status \u003cstatus\u003e]\n```\n\nExample:\n\n```bash\nlist-if-diff --since v1.3.1 --file-path my-app.yml | xargs eslint\n```\n\n### `run-if-diff`\n\nRun a command and passthru it's output if matching files have changed.\n\n```bash\nrun-if-diff [--since \u003cref\u003e] [--file-path \u003cglob\u003e] [--file-status \u003cstatus\u003e] -- \u003ccmd\u003e\n```\n\nExample:\n\n```bash\nrun-if-diff --since v1.3.1 --file-path my-app.yml -- aws cfn deploy --stack-name my-app --template-file my-app.yml\n```\n\n### Github action\n\nCheck whether files have changed in a pipeline.\n\n```yml\nsteps:\n  - uses: actions/checkout@v2\n\n  - id: run-if-diff\n    uses: jameslnewell/run-if-diff@master\n    with:\n      cwd: .\n      since: previous-tag\n      file-path: |\n        apps/**/*.tsx\n        packages/**/*.tsx\n      file-status: |\n        A\n        M\n\n  - name: Get the ref\n    run: 'echo \"ref: ${{ steps.run-if-diff.outputs.ref }}\"'\n\n  - name: Get the file count\n    run: 'echo \"count: ${{ steps.run-if-diff.outputs.count }}\"'\n\n  - name: Get the file paths\n    run: 'echo -e \"paths: \\n${{ steps.run-if-diff.outputs.paths }}\"'\n\n  - name: Conditional command\n    if: ${{ steps.run-if-diff.outputs.count \u003e 0 }}\n    run: echo \"Expensive command...\"\n```\n\n## Credits\n\nInspired by `lerna`'s `--since` filter.\n\n## License\n\nCopyright 2018 James Newell\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameslnewell%2Frun-if-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameslnewell%2Frun-if-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameslnewell%2Frun-if-diff/lists"}