0

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

  • I think you should setup something similar to what is mentioned under the heading "Waiting" on that page - https://www.npmjs.com/package/grunt-run I guess, you should kick start a browser instance, instead of trying to just run a html file. – ArunGeorge Jul 20 '16 at 11:17

1 Answers1

0

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');
Community
  • 1
  • 1
MarcoL
  • 9,829
  • 3
  • 37
  • 50