-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(action): reuse args from package.json #106
feat(action): reuse args from package.json #106
Conversation
README.md
Outdated
@@ -33,6 +33,8 @@ npx sherif@latest | |||
|
|||
We recommend running Sherif in your CI once [all errors are fixed](#autofix). Run it by **specifying a version instead of latest**. This is useful to prevent regressions (e.g. when adding a library to a package but forgetting to update the version in other packages of the monorepo). | |||
|
|||
By default, it will search for a `sherif` script in the root `package.json` and try to use the same arguments, so you can avoid repeating yourself. But you can override this behaviour with the `args` param. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, it will search for a `sherif` script in the root `package.json` and try to use the same arguments, so you can avoid repeating yourself. But you can override this behaviour with the `args` param. | |
When using the GitHub Action, it will search for a `sherif` script in the root `package.json` and use the same arguments automatically to avoid repeating them twice. You can override this behaviour with the `args` parameter. |
action/index.ts
Outdated
core.info('No scripts found in package.json'); | ||
return; | ||
} | ||
|
||
if (!('sherif' in packageJson.scripts)) { | ||
core.info('No sherif script found in package.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to log here, it could get noisy for nothing.
} | ||
|
||
// Select the args of the sherif script | ||
const regexResult = /sherif\s([a-zA-Z\s\.-]*)(?=\s&&|$)/g.exec( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to explain what this regex does?
action/index.ts
Outdated
); | ||
if (regexResult && regexResult.length > 1) { | ||
const args = regexResult[1]; | ||
core.info(`Found args "${args}" package.json`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core.info(`Found args "${args}" package.json`); | |
core.info(`Using the arguments "${args}" from the root package.json`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
If the action doesn't have the
args
param, and the root package.json contains a script called "sherif", pass the arguments of the sherif script to the action to avoid repeating the same args in the root package.json and the action