我如何使用 grunt 打开 Google Chrome 并传递像 --incognito 这样的标志?

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

我正在为本地开发服务器使用 grunt-contrib-connect,并希望编写一个任务以在服务器启动后启动 google chrome。但是想要传递以下参数以在不安全模式下打开它。

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

我尝试使用 grunt-open 来执行此操作,但没有找到任何传递标志的选项。

感谢任何帮助。

您应该能够使用 grunt-exec 来做您需要的事情。这样的配置对我有用:

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

请注意,在 Windows 上,可执行文件的路径需要引号。如果你足够幸运,用得不那么烦人OS,你就不需要它们了。