1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +01:00

Fix homedir for manifests

This commit is contained in:
Hinton 2020-10-16 18:51:28 +02:00
parent 74b51c9a6c
commit 1bb81270d9

View File

@ -2,6 +2,7 @@ import { promises as fs, existsSync } from 'fs';
import * as ipc from 'node-ipc'; import * as ipc from 'node-ipc';
import * as path from 'path'; import * as path from 'path';
import * as util from 'util'; import * as util from 'util';
import { homedir } from 'os';
import { LogService } from 'jslib/abstractions/log.service'; import { LogService } from 'jslib/abstractions/log.service';
import { MessagingService } from 'jslib/abstractions/messaging.service'; import { MessagingService } from 'jslib/abstractions/messaging.service';
@ -80,25 +81,26 @@ export class NativeMessagingMain {
this.createWindowsRegistry('HKCU\\SOFTWARE\\Google\\Chrome', 'HKCU\\SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\com.8bit.bitwarden', path.join(destination, 'chrome.json')) this.createWindowsRegistry('HKCU\\SOFTWARE\\Google\\Chrome', 'HKCU\\SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\com.8bit.bitwarden', path.join(destination, 'chrome.json'))
break; break;
case 'darwin': case 'darwin':
if (existsSync('~/Library/Application Support/Mozilla/')) { if (existsSync(`${homedir()}/Library/Application\ Support/Mozilla/`)) {
fs.mkdir('~/Library/Application Support/Mozilla/NativeMessagingHosts/'); fs.mkdir(`${homedir()}/Library/Application\ Support/Mozilla/NativeMessagingHosts/`);
this.writeManifest('~/Library/Application Support/Mozilla/NativeMessagingHosts/com.8bit.bitwarden.json', firefoxJson); this.writeManifest(`${homedir()}/Library/Application\ Support/Mozilla/NativeMessagingHosts/com.8bit.bitwarden.json`, firefoxJson);
} }
if (existsSync('~/Library/Application Support/Google/Chrome/')) { if (existsSync(`${homedir()}/Library/Application\ Support/Google/Chrome`)) {
fs.mkdir('~/Library/Application Support/Google/Chrome/NativeMessagingHosts/'); console.log("FOUND CHROME");
this.writeManifest('~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.8bit.bitwarden.json', chromeJson); fs.mkdir(`${homedir()}/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/`);
this.writeManifest(`${homedir()}/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.8bit.bitwarden.json`, chromeJson);
} }
break; break;
case 'linux': case 'linux':
if (existsSync('~/.mozilla/')) { if (existsSync(`${homedir()}/.mozilla/`)) {
fs.mkdir('~/.mozilla/native-messaging-hosts'); fs.mkdir(`${homedir()}/.mozilla/native-messaging-hosts`);
this.writeManifest('~/.mozilla/native-messaging-hosts/com.8bit.bitwarden.json', firefoxJson); this.writeManifest(`${homedir()}/.mozilla/native-messaging-hosts/com.8bit.bitwarden.json`, firefoxJson);
} }
if (existsSync('~/.config/google-chrome/')) { if (existsSync(`${homedir()}/.config/google-chrome/`)) {
fs.mkdir('~/.config/google-chrome/NativeMessagingHosts/'); fs.mkdir(`${homedir()}/.config/google-chrome/NativeMessagingHosts/`);
this.writeManifest('~/.config/google-chrome/NativeMessagingHosts/com.8bit.bitwarden.json', chromeJson); this.writeManifest(`${homedir()}/.config/google-chrome/NativeMessagingHosts/com.8bit.bitwarden.json`, chromeJson);
} }
break; break;
default: default: