How to detect the platform lefthook is running on (Linux/Windows/MacOS), and run scripts specific for each platform? #999
-
|
The question from the title. So, I have a couple of scripts to check for BOM presence, line length enforcement, copying some files around, etc, and I have Bash and PowerShell versions of each script. I work with .NET/C# projects, so it is very common for these projects to be open and worked on both Windows and Linux. Given this, I'd like to run the PS scripts only on Windows, and the Bash ones on Linux/MacOS. I didn't manage to find anything of the sort in the docs, hence the question: Is there a way of identifying the platform that Lefthook is running on, and then, based on this information, run a set of scripts or another? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Related |
Beta Was this translation helpful? Give feedback.
-
|
You can use a workaround I think pre-commit:
jobs:
- only:
- run: uname # only on linux/macos
script: your-shell-script.sh
- only:
- run: cmd /c ver # only on windows
script: your-powershell-script.ps1Or with commands pre-commit:
jobs:
- only:
- run: uname # only on linux/macos
run: echo 'Hello from *nix'
- only:
- run: cmd /c ver # only on windows
run: echo 'Hello from Windows'You can check the docs on |
Beta Was this translation helpful? Give feedback.
You can use a workaround I think
Or with commands
You can check the docs on
skipoption, theonlyhas similar configuration.