gruntjsgrunt-contrib-connect

How can I use grunt to open Google Chrome and pass flags like --incognito?


I am using grunt-contrib-connect for a local dev server and want to write a task to launch google chrome after server starts. But want to pass following arguments to open it in insecure mode.

--args --disable-web-security --user-data-dir

I tried grunt-open to do that but didn't find any options to pass flags.

Any help is appreciated.


Solution

  • You should be able to use grunt-exec to do what you need. A configuration like this works for me:

    grunt.config.init({
        ...
        exec: {
            chrome: {
                cmd: '"C:/Program Files (x86)/Google/Chrome/Application/chrome" --incognito http://washingtonpost.com'
            }
        }
        ...
    });
    

    Note that, on Windows, quotes are required around the path to the executable. If you're fortunate enough to be using less annoying OS, you won't need them.