grunt-open for two different files

女生的网名这么多〃 提交于 2019-12-25 04:57:24

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/38549992/grunt-open-for-two-different-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!