Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Added support for Chrome beta, dev and canary (#221)
Browse files Browse the repository at this point in the history
* Support chrome beta, dev and canary

* fixed canary dir for macos
  • Loading branch information
lucacasonato authored and Nathan Potter committed Jun 20, 2019
1 parent 2125c9e commit 2afe9a3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func (c *chromeExtInstall) Run(fl *flag.FlagSet) {
}

for _, dir := range nativeHostDirs {
if dir == "" {
continue
}

err = os.MkdirAll(dir, 0755)
if err != nil {
flog.Fatal("failed to ensure manifest directory exists: %v", err)
Expand Down Expand Up @@ -146,14 +150,20 @@ func nativeMessageHostManifestDirectories() ([]string, error) {
}

var chromeDir string
var chromeBetaDir string
var chromeDevDir string
var chromeCanaryDir string
var chromiumDir string

switch runtime.GOOS {
case "linux":
chromeDir = path.Join(homeDir, ".config", "google-chrome", "NativeMessagingHosts")
chromeBetaDir = path.Join(homeDir, ".config", "google-chrome-beta", "NativeMessagingHosts")
chromeDevDir = path.Join(homeDir, ".config", "google-chrome-unstable", "NativeMessagingHosts")
chromiumDir = path.Join(homeDir, ".config", "chromium", "NativeMessagingHosts")
case "darwin":
chromeDir = path.Join(homeDir, "Library", "Application Support", "Google", "Chrome", "NativeMessagingHosts")
chromeCanaryDir = path.Join(homeDir, "Library", "Application Support", "Google", "Chrome Canary", "NativeMessagingHosts")
chromiumDir = path.Join(homeDir, "Library", "Application Support", "Chromium", "NativeMessagingHosts")
default:
return nil, xerrors.Errorf("unsupported os %q", runtime.GOOS)
Expand All @@ -162,5 +172,8 @@ func nativeMessageHostManifestDirectories() ([]string, error) {
return []string{
chromeDir,
chromiumDir,
chromeBetaDir,
chromeDevDir,
chromeCanaryDir,
}, nil
}

0 comments on commit 2afe9a3

Please sign in to comment.