Run project exsiting HTML file after code coverage finish in grunt

假装没事ソ 提交于 2020-01-07 07:43:51

问题


I've node app which use grunt to generate code coverage report this report is located under and I was able to run it manually

myAPP
 -coverage
  -index.html

I want that when the task of coverage will finish and the report is generated to run this index.html in the browser,how should I do that? I found this

https://www.npmjs.com/package/grunt-run

but its not working

I try many ways

grunt.initConfig({
  run: {
    commands: {
      exec: '/coverage/lcov-report/index.html',
    }
  }
});

or

grunt.initConfig({
  run: {
      path: '/coverage/lcov-report/index.html',
    }

});

Maybe I'm not using it well I just want to run existing html file from my project with some grunt task


回答1:


To open a webpage with the browser in NodeJS there are some modules that let's you do that cross-platform.

Luckily for you there's a grunt plugin that integrates with open: grunt-open .

When configuring it tell the URL of the index.html:

grunt.initConfig({
  open : {
    file : {
      // Put here the absolute path of the file
      path : '/path/to/coverage/lcov-report/index.html'
    }
  }
});

grunt.loadNpmTasks('grunt-open');


来源:https://stackoverflow.com/questions/38474419/run-project-exsiting-html-file-after-code-coverage-finish-in-grunt

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