Skip to content

Accumulating scripts to avoid running multiple times #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brettz9 opened this issue Aug 17, 2020 · 1 comment
Closed

Accumulating scripts to avoid running multiple times #42

brettz9 opened this issue Aug 17, 2020 · 1 comment
Milestone

Comments

@brettz9
Copy link

brettz9 commented Aug 17, 2020

This request can probably be best explained with an example.

{
    "src": "npm test && npm run build && npm run check-readme",
    "test": "npm test && npm run create-readme",
}

...I don't want to re-run test if both src and test files are modified.

Is there a way it could be recognized such that npm test wouldn't need to be repeated?

@hkdobrev hkdobrev modified the milestones: 1.0, 1.x Aug 6, 2024
@hkdobrev
Copy link
Owner

@brettz9 Hi! Sorry for the late reply, but with the more recent changes this is now possible.

You can configure it using arrays like this:

{
    "src": ["npm test", "npm run build", "npm run check-readme"],
    "test": ["npm test", "npm run create-readme"],
}

The whole hook would fail if any of the commands return a non-zero exit code and would stop further execution.
The commands would be run in order, but only once regardless of how many file patterns matched which caused them to run.

If you change both src and test in one Git operation, run-if-changed would run:

npm test
npm run build
npm run check-readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants