pocesar/grunt-mocha-istanbul

process args are overwritten

Closed this issue · 5 comments

I was trying to run grunt with some command line arguments and realized they disappear by the time my tests get invoked. Looking at the code, I see var args = [] where I would expect it to be something along the lines of var args = process.argv || []

Is that behavior intentional?
Cheers!

yes, the args for the process spawning are created internally with no regards from external arguments from the command line. The arguments are passed using grunt options instead of the command line (so the task is 'portable', it will always work the same expected way every time)
if you need extra arguments passed to the underlaying processes (node / mocha / istanbul), you can use nodeOptions, mochaOptions, istanbulOptions arrays, respectively. (nodeOptions is only available in this branch https://github.com/pocesar/grunt-mocha-istanbul/tree/issue%2349#optionsnodeoptions)

Ah cool, that makes total sense. I'm improving an existing build system, so I need to support command line args. Looks like I'll need to use mochaOptions. @pocesar thanks for the explanation!

@pocesar one more question. Are you planning to release nodeOptions as a stable feature? That would be fantastic. I remember having problems shrinkwrapping packages when pointing to github for dependencies.

Never mind, I made it work with mochaOptions. Had some confusion about how node flags work in general. Good talk, good talk :)

@kahluagenie yes I do, I was expecting some feedback from people on issue #49 before merging to master and releasing it. I could put some additional info on the docs about the order of the flags (node > istanbul > mocha)