{"id":42404480,"url":"https://github.com/hkdobrev/run-if-changed","last_synced_at":"2026-01-28T01:31:14.040Z","repository":{"id":33973275,"uuid":"164142227","full_name":"hkdobrev/run-if-changed","owner":"hkdobrev","description":"Run a command if a file changes via Git hooks","archived":false,"fork":false,"pushed_at":"2026-01-23T05:23:20.000Z","size":360,"stargazers_count":37,"open_issues_count":14,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-23T22:48:08.857Z","etag":null,"topics":["cli","devops","git-hooks","git-workflow","javascript","nodejs"],"latest_commit_sha":null,"homepage":"https://hkdobrev.com/run-if-changed/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hkdobrev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-01-04T18:35:30.000Z","updated_at":"2026-01-06T17:53:39.000Z","dependencies_parsed_at":"2023-01-15T03:43:55.510Z","dependency_job_id":"3cdfe89a-6c74-4ed4-8593-7d748a0816b1","html_url":"https://github.com/hkdobrev/run-if-changed","commit_stats":{"total_commits":71,"total_committers":4,"mean_commits":17.75,"dds":"0.15492957746478875","last_synced_commit":"395f831050cadcfb6e921c0c7ecbc0f78d789240"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/hkdobrev/run-if-changed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdobrev%2Frun-if-changed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdobrev%2Frun-if-changed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdobrev%2Frun-if-changed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdobrev%2Frun-if-changed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hkdobrev","download_url":"https://codeload.github.com/hkdobrev/run-if-changed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkdobrev%2Frun-if-changed/sbom","scorecard":{"id":466112,"data":{"date":"2025-08-11","repo":{"name":"github.com/hkdobrev/run-if-changed","commit":"38ca810f0984ff16a3fda4ad4ec8105d0768457d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":10,"reason":"18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 1/7 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/publish.yml:30","Info: jobLevel 'contents' permission set to 'read': .github/workflows/publish.yml:47","Warn: jobLevel 'packages' permission set to 'write': .github/workflows/publish.yml:49","Warn: no topLevel permission defined: .github/workflows/js_test.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/js_test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/js_test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/js_test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/js_test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/hkdobrev/run-if-changed/publish.yml/main?enable=pin","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   4 out of   4 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T12:33:12.614Z","repository_id":33973275,"created_at":"2025-08-19T12:33:12.614Z","updated_at":"2025-08-19T12:33:12.614Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28831528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","devops","git-hooks","git-workflow","javascript","nodejs"],"created_at":"2026-01-28T01:31:13.985Z","updated_at":"2026-01-28T01:31:14.033Z","avatar_url":"https://github.com/hkdobrev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔃 run-if-changed [![npm version](https://img.shields.io/npm/v/@hkdobrev/run-if-changed.svg)](https://www.npmjs.com/package/@hkdobrev/run-if-changed)\n\nRun a command if a file changes via Git hooks.\nUseful for lock files or build systems to keep dependencies and generated files up to date when changing branches, pulling or commiting.\n\nInspired by [`lint-staged`](https://github.com/okonet/lint-staged) and recommended to be used with [`husky`](https://github.com/typicode/husky).\n\n#### State of the project\n\nrun-if-changed is functional as-is, but it's still quite basic and rough as it has just been published. So issues, feature requests and pull requests are most welcome!\n\n## Installation and setup\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003eInstall with npm\u003c/b\u003e\u003c/summary\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-shell\"\u003e\nnpm install --save-dev husky @hkdobrev/run-if-changed\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch5\u003eRecommended setup\u003c/h5\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n\"run-if-changed\": {\n  \"package-lock.json\": \"npm install --prefer-offline --no-audit\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eInstall with Yarn\u003c/b\u003e\u003c/summary\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-shell\"\u003e\nyarn add --dev husky @hkdobrev/run-if-changed\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch5\u003eRecommended setup\u003c/h5\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n\"run-if-changed\": {\n  \"yarn.lock\": \"yarn install --prefer-offline --pure-lockfile --color=always\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\u003c/details\u003e\n\n### Set up Git hooks\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003eUsing \u003ca href=\"https://typicode.github.io/husky/\"\u003e\u003ccode\u003ehusky\u003c/code\u003e\u003c/a\u003e\u003c/b\u003e\u003c/summary\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-shell\"\u003e\necho \"npx run-if-changed\" \u003e .husky/post-commit\necho \"npx run-if-changed\" \u003e .husky/post-checkout\necho \"npx run-if-changed\" \u003e .husky/post-merge\necho \"npx run-if-changed\" \u003e .husky/post-rewrite\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eJust git hooks\u003c/b\u003e\u003c/summary\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-shell\"\u003e\necho \"npx run-if-changed\" \u003e\u003e .git/hooks/post-commit \u0026\u0026 chmod +x .git/hooks/post-commit\necho \"npx run-if-changed\" \u003e\u003e .git/hooks/post-checkout \u0026\u0026 chmod +x .git/hooks/post-checkout\necho \"npx run-if-changed\" \u003e\u003e .git/hooks/post-merge \u0026\u0026 chmod +x .git/hooks/post-merge\necho \"npx run-if-changed\" \u003e\u003e .git/hooks/post-rewrite \u0026\u0026 chmod +x .git/hooks/post-rewrite\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n## Why\n\nThe use case for `run-if-changed` is mostly for a team working on a project and push and pull code in different branches. When you share dependencies, database migrations or compilable code in the shared Git repository often some commands need to be run when a file or folder gets updated.\n\nCheck out the [common use cases](#use-cases).\n\n## Configuration\n\n- `run-if-changed` object in your `package.json`\n- `.run-if-changedrc` file in JSON or YML format\n- `run-if-changed.config.js` file in JS format\n\nSee [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for more details on what formats are supported.\n\nConfiguration should be an object where each key is a file or directory match pattern and the value is either a single command or an array of commands to run if the file have changed since the last Git operation.\n\n## What commands are supported?\n\nSupported are any executables installed locally or globally via `npm` or Yarn as well as any executable from your `$PATH`.\n\n\u003e Using globally installed scripts is discouraged, since run-if-changed may not work for someone who doesn't have it installed.\n\n`run-if-changed` is using [`execa`](https://github.com/sindresorhus/execa) to locate locally installed scripts and run them. So in your `.run-if-changedrc` you can just write and it would use the local version:\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"src\": \"webpack\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\nSequences of commands are supported. Pass an array of commands instead of a single one and they will run sequentially.\n\n## Use cases\n\n#### Install or update dependencies when lock file changes\n\nIf you use a dependency manager with a lock file like npm, Yarn, Composer, Bundler or others, you would usually add a dependency and the dependency manager would install it and add it to the lock file in a single run. However, when someone else has updated a dependency and you pull new code or checkout their branch you need to manually run the install command of your dependency manager.\n\nHere's example configuration of `run-if-changed`:\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003enpm\u003c/b\u003e\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"package-lock.json\": \"npm install --prefer-offline --no-audit --no-fund\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ccode\u003e.run-if-changedrc\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"package-lock.json\": \"npm install --prefer-offline --no-audit --no-fund\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eYarn\u003c/b\u003e\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"yarn.lock\": \"yarn install --prefer-offline --pure-lockfile --color=always --non-interactive\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ccode\u003e.run-if-changedrc\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"yarn.lock\": \"yarn install --prefer-offline --pure-lockfile --color=always --non-interactive\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eComposer\u003c/b\u003e\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"composer.lock\": \"composer install --ignore-platform-reqs --ansi\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eBundler\u003c/b\u003e\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"Gemfile.lock\": \"bundle install --prefer-local\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n#### Run database migrations if there are new migrations\n\nIf you keep database migrations in your repository, you'd usually want to run them when you check out a branch or pull from master.\n\n\u003cdetails\u003e\n\u003csummary\u003eExample of running Doctrine migrations when pulling or changing branches\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"migrations\": \"./console db:migrate --allow-no-migration --no-interaction\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n\n#### Compile sources in a build folder after pulling new code.\n\n\u003cdetails\u003e\n\u003csummary\u003eExample for running build on changing src folder when pulling or changing branches\u003c/summary\u003e\n\n\u003ccode\u003epackage.json\u003c/code\u003e\n\n\u003cpre\u003e\u003ccode class=\"language-json\"\u003e\n{\n  \"run-if-changed\": {\n    \"src\": \"npm run build\"\n  }\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkdobrev%2Frun-if-changed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkdobrev%2Frun-if-changed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkdobrev%2Frun-if-changed/lists"}