When the command grunt
is run in a Windows shell in the same path as the grunt.js file, Windows opts to run grunt.js using the Windows Script Host. The recommended path is to explicitly call grunt.cmd
.
That's all fine and dandy, but what can I do if I want to create an OS-independent script command in my NPM package.json? I can't do this if I want to also run in *nix:
"scripts": {
"dox": "grunt.cmd dox"
}
Any pointers? Or, is there a big piece of the puzzle that I'm missing? (I'm equally new to both NPM and Grunt).
I've found the solution in creating a grunt.bat
file that just calls grunt.cmd
:
@grunt.cmd %*
Therefore, on Windows, just invoking grunt
triggers the batch file since it gets higher priority than Windows Scripting Host's picking up of grunt.js
. On Linux, the regular grunt
binary gets picked up. This works cross-platform for me now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With