OS-independent grunt script command in NPM package.json

When the grunt command is run in the Windows shell in the same way as the grunt.js file, Windows chooses to run grunt.js using the Windows Script Host. The recommended way is to explicitly call grunt.cmd .

That everything is 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 not do this if I want to also run on * nix:

 "scripts": { "dox": "grunt.cmd dox" } 

Any pointers? Or is there a big part of the puzzle that I missed? (I am also new to both NPM and Grunt.)

+6
source share
1 answer

I found a solution when creating a grunt.bat file that just calls grunt.cmd :

  @ grunt.cmd% *

Therefore, on Windows, just the calling grunt runs the batch file, since it gets a higher priority than the Windows Scripting Host, which takes grunt.js . On Linux, ordinary binary grunt gets. Now for me it is a cross-platform platform.

+7
source

All Articles