1.0.14 • Published 4 years ago
monorepo-staged-precommit v1.0.14
monorepo-staged-precommit
This package adds a pre-commit hook script that runs the precommit script in all package.json's in projects where there are staged changes.
Uses nvm use to use the correct node version for each project.
Does not run on CI.
Usage
- add to all
package.jsonfiles in monorepo by runningnpm i --save-dev monorepo-staged-precommitin all folders containg package.json. (can be done in one, yet only when installing a project with it, will the precommit-hook script be added). - add
precommitscript to package.json. (e.g."precommit": "lint-staged"). - make changes and stage them.
- run
git commit. - allprecommitscripts will run in projects with changes.
Example
Given monorepo:
- project
|
|-- projectA
| |
| |-- package.json
|
|-- projectB
| |
| |--package.json
|
|-- projectCWhen changing a file in projectA and staging it, the script will run the
precommitscript inprojectA/pacakge.json.When changing a file in projectA and projectB and staging them the script will run the
precommitscript in bothproject/package.jsonandprojectB/package.json.When changing a file in projectC and staging it nothing will run since projectC has no package.json.