Skip to content
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

PRE / POST commands at descriptor level #3450

Closed
bdovaz opened this issue Mar 26, 2024 · 3 comments · Fixed by #3468
Closed

PRE / POST commands at descriptor level #3450

bdovaz opened this issue Mar 26, 2024 · 3 comments · Fixed by #3468
Labels
enhancement New feature or request

Comments

@bdovaz
Copy link
Collaborator

bdovaz commented Mar 26, 2024

Right now they can only be created at the global or linter level, but not at the descriptor level:

https://megalinter.io/latest/descriptors/php/

Example: I want to run composer install for all PHP linters but I only want this command to run if it finds *.php files and not always run it even if there are no php files in the analysis what would happen if I do it with the commands globally.

@bdovaz bdovaz added the enhancement New feature or request label Mar 26, 2024
@nvuillam
Copy link
Member

@bdovaz that's a good proposition :)

Would you like to make the PR ?

It should be something like adding methods run_descriptor_pre_commands(descriptor_id) and run_descriptor_post_commands(descriptor_id) and call them from the appropriate places

image

@bdovaz
Copy link
Collaborator Author

bdovaz commented Apr 2, 2024

@nvuillam I am looking at it but I have a doubt.

That is where the linters are processed:

self.process_linters_parallel(active_linters, linters_do_fixes)

What contains "active_linters" are only the ones that are going to be executed? I mean, if I have in my repo only *.py files and I haven't activated/deactivated any linter in the .megalinter.yml configuration, in that list I will only get the linters that process *.py extensions?

Because I only need those that are going to be executed (not the total) to be able to extract from them the "descriptor_id" and from there to make the call to the pre and post of each descriptor in case it is established.

@nvuillam
Copy link
Member

nvuillam commented Apr 2, 2024

@bdovaz yes active_linters contain only those that will be executed :)

the filtering is done before with collect_files, any linter is set inactive if there is no matching file here

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

Successfully merging a pull request may close this issue.

2 participants