Rayn D Rayn D - 2 months ago 8x
Node.js Question

grunt open for two diffrent files

grunt open for two diffrent files

I use the grunt open plugin which works OK.
Now I need to open additional file with diffrent task
How should I do that?

I try with

open: {
file: {
path: appPath + '/coverage/lcov/index.html',
path2: appPath + '/coverage/lcov-report/index2.html'

//Here I want to open first line
grunt.registerTask('openCoverage', ['exec', 'copy', 'mocha_istanbul', 'open:path']);
//Here I want to map second line
grunt.registerTask('MochaWeb', ['exec', 'copy', 'mochaTest', 'open:path2']);


From the documentation it is clear that the path parameter holds the filepath of the file you want to open. You won't be able to add suffixed versions of "path", like path2. Instead, you will need to use separate targets for each file you wish to open. Your config would then look like the following:

open: {
    openCoverage: {
        path: appPath + '/coverage/lcov/index.html'
    MochaWeb: {
        path: appPath + '/coverage/lcov-report/index2.html'

Next, you will add these targets to your task definitions:

grunt.registerTask('openCoverage', ['exec', 'copy', 'mocha_istanbul', 'open:openCoverage']);
grunt.registerTask('MochaWeb', ['exec', 'copy', 'mochaTest', 'open:MochaWeb']);