代码覆盖完成后,运行项目存在的HTML文件 [英] Run project exsiting HTML file after code coverage finish in grunt

查看:90
本文介绍了代码覆盖完成后,运行项目存在的HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用grunt生成代码覆盖率报告
的节点应用程序,该报告位于下方,我可以手动运行它。

  myAPP 
-coverage
-index.html

我希望当覆盖任务完成并生成报告以在浏览器中运行此index.html时,我该怎么做?
我发现了这个



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



但它不工作

我尝试了很多方法

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

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

}) ;

也许我没有使用它我只想从我的项目中运行现有的html文件grunt任务

解决方案

使用NodeJS中的浏览器打开网页有一些模块可以让你做跨平台。 / p>

幸运的是,有一款与集成的grunt插件打开 grunt-open



配置它时,会告诉 index.html 的网址:

  grunt.initConfig({
open:{
file:{
//在这里放置文件的绝对路径
path:'/ path / to / coverage /lcov-report/index.html'
}
}
});

grunt.loadNpmTasks('grunt-open');


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

解决方案

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

这篇关于代码覆盖完成后,运行项目存在的HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆