Husky is a convenient way of auto-adding Git hooks during npm install or yarn install. But more importantly, it is a way of providing platform independence for hook scripts. This blog post uses #!/bin/bash. But what if the developer does not have sh? (As is the case for most Windows users.) By contrast, we do have the guarantee that every user of husky has NodeJs.
This is * #!/bin/sh not #!/bin/bash. I added an example to this blog post. You can download it and check that this will work on Windows too: git-hooks-example
I didn't claim it was bash. The Windows command line interpreter definitely cannot run arbitrary sh scripts, which are a Unix standard. Let alone certain basic commands - for example cp is for copying files on Unixoids, but copy must be used on Windows. It's interesting that your script runs on Windows. I see two possible explanations: Either your script is so parsimonious that its syntax is valid both in sh and on Windows. Or somehow Git, or your Git installation, brings sh with it. It would be interesting to figure out if the second explanation is true. It would also be interesting to know if, for example, you could use the cp command on Windows from a sh script like yours above.
you can if you install winbash, which is different from msysgit bash in that winbash actually treats windows paths as windows paths, where as msysgit bash mutates them to some virtual-path-that-like-linux-but-not-really-linux.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Husky is a convenient way of auto-adding Git hooks during
npm installoryarn install. But more importantly, it is a way of providing platform independence for hook scripts. This blog post uses#!/bin/bash. But what if the developer does not havesh? (As is the case for most Windows users.) By contrast, we do have the guarantee that every user of husky has NodeJs.This is *
#!/bin/shnot#!/bin/bash. I added an example to this blog post. You can download it and check that this will work on Windows too: git-hooks-exampleI didn't claim it was
bash. The Windows command line interpreter definitely cannot run arbitraryshscripts, which are a Unix standard. Let alone certain basic commands - for examplecpis for copying files on Unixoids, butcopymust be used on Windows. It's interesting that your script runs on Windows. I see two possible explanations: Either your script is so parsimonious that its syntax is valid both inshand on Windows. Or somehow Git, or your Git installation, bringsshwith it. It would be interesting to figure out if the second explanation is true. It would also be interesting to know if, for example, you could use thecpcommand on Windows from ashscript like yours above.you can if you install winbash, which is different from msysgit bash in that winbash actually treats windows paths as windows paths, where as msysgit bash mutates them to some virtual-path-that-like-linux-but-not-really-linux.