simple-git-hooks
simple-git-hooks copied to clipboard
Add windows compatibility to `npx simple-git-hooks` when configured by `.js` file
When setting the configuration from js
file (simple-git-hooks.js
or .simple-git-hooks.js
)
the npx simple-git-hooks
command executed on Windows 10 returns an error:
Line: 1
Char: 1
Error: 'module' is not defined
Source: Microsoft JScript runtime error
The problem happens because for some reason Windows might use internal JS interpreter instead of node. This internal interpreter does not know what module
is, thus throwing an error.
--
Possible workaround for now is to use configuration from package.json
or simple-git-hooks.json
files.
Also changing the default interpreter might help
Hey, actually it did work for me today. I'm on windows 10 with configuration in .simple-git-hooks.js
.
Here is PR if you want to check settings/deps/etc.: https://github.com/nolimits4web/swiper/pull/4417
P.S Using bash if relevant
The problem is that Windows doesn't support shebangs. So, running foo.js will use the default program associated with .js files, which is usually wscript. The solution is to use exec from Node.js and use node foo.js
across the codebase.