-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Currently, I have three package.json files - one at the workspace root, and two in sub-packages. I'd like to use package-changed from a script in the main package.json
For example (I am using pnpm):
./package.json (root folder):
{
"scripts": {
"package-changed": "package-changed run 'rm -f .eslintcache && pnpm install'"
},
"dependencies": {
"subprojecta": "workspace:subprojecta",
"subprojectb": "workspace:subprojectb"
},
"devDependencies": {
"eslint": "^8.50.0",
"husky": "^8.0.3",
"package-changed": "^3.0.0"
}
}./subprojecta/package.json
{
"devDependencies": {
"typescript": "^5.2.2"
}
}./subprojectb/package.json
{
"devDependencies": {
"next": "^13.5.4"
}
}If the main package.json changes, or either of the subproject package.jsons change, I want the package-changed task to run.
I think this would be relatively simple, all things considered. Trickiest part would be detecting the workspaces in the first place (i.e. changes to src/find-package.ts). After that, I think it'd just require src/get-package-hash.ts to concatenate the various package.json files before hashing.
As an alternative to searching for multiple package.json files, there could also just be explicit cli-provided paths, e.g.
"package-changed": "package-changed --package ./package.json --package ./subprojecta/package.json --package ./subprojectb/package.json run 'rm -f .eslintcache && pnpm install'"
Right now, I think the only existing options are to either:
- have separate package-changed scripts in each subproject and a script at the root that runs both
- use the js api to manually run on multiple cwd