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

Add a pre-commit hook for psscriptanalyzer #1969

Open
winterz opened this issue Feb 22, 2024 · 2 comments
Open

Add a pre-commit hook for psscriptanalyzer #1969

winterz opened this issue Feb 22, 2024 · 2 comments

Comments

@winterz
Copy link

winterz commented Feb 22, 2024

it would be quite useful if I could use thehttps://pre-commit.com/tool to run PSScriptAnalyzer on my powershell scripts during the git commit stage. then I could find problems in my powershell code before they land into git repositories.

information how about to write a pre-commit hook can be found at https://pre-commit.com/#new-hooks
Proposed technical implementation details (optional)

for example, a pre-commit hook for pylint (the python linter) is at https://github.com/pylint-dev/pylint

@bergmeister
Copy link
Collaborator

@winterz What do you expect PSScriptAnalyzer to do to enable that? Because it is a PowerShell based tool and therefore not in the list of supported languages here: https://pre-commit.com/#supported-languages
But it has script support so I assume that goes to bash or cmd depending on OS and you could write a small script that calls PowerShell to then call PSScriptAnalyzer and use the -EnableExitCode switch to signal success/failure

@winterz
Copy link
Author

winterz commented Apr 9, 2024

right. I had forgotten about the supported languages problem.
oh well. just an idea.
feel free to close this

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

No branches or pull requests

2 participants