grunt-reload-chrome

0.1.4 • Public • Published

grunt-reload-chrome Build Status

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-reload-chrome --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-reload-chrome');

Reload Chrome task

Run this task with the grunt reload command.

Task targets and options may be specified according to the grunt Configuring tasks guide.

This grunt tasks makes use of the chrome-remote-interface package.

So first Chrome needs to be started with the --remote-debugging-port=<port> option to enable the Remote Debugging Protocol, for example:

google-chrome --remote-debugging-port=9222

Usage Examples

 reload: {
  homepage: {
    options: {
      url: 'http://localhost:5000/'
      match: /Chi/
    }
  },
  current: {
    options: {
      match: /Chi/
    }
  },
  eval: {
    options: {
      host: '192.168.1.23',
      port: 1024,
      match: /Chi/,
      scriptEvaluateOnLoad: 'alert("hi!")'
    }
  }
}

With match you specify the title to match, it can be a regular expression or just an exact string. The tab must already be opened within your browser.

If you specify an url, the location will be set to that exact url. If you specify nothing the url will be replaced with itself causing it to reload the current page.

host and port can be used if your remote debugging port is something else than the default of 9222.

If you feel adventurous you can also use the scriptEvaluateOnLoad option, to run a script each time the tab is reloaded, which might come in handy to automate stuff even more.

Note: The detected tab will not reload if it has DevTools opened at the moment of reload.

Resources

Release History


  • 2013-12-01   v0.1.4   Fix RegExp matching
  • 2013-11-23   v0.1.3   expose scriptEvaluateOnLoad & proper tagging.
  • 2013-11-23   v0.1.2   Forgot.
  • 2013-11-23   v0.1.1   Forgot.
  • 2013-11-22   v0.1.0   Initial version.

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-reload-chrome

Weekly Downloads

7

Version

0.1.4

License

MIT

Last publish

Collaborators

  • rhalff