Rayn D Rayn D - 1 year ago 57
Node.js Question

grunt-open for two different files

grunt-open for two different files

I use the grunt-open plugin which works OK.
Now I need to open an additional file with a different task.
How can I do that?

I have tried:

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']);