tweak CLI install text

This commit is contained in:
Jeffrey Morgan 2023-07-06 12:23:08 -04:00
parent 03eca6ea54
commit 0833f5af3a

View file

@ -1,6 +1,7 @@
import { app, BrowserWindow, autoUpdater, dialog } from 'electron' import { app, BrowserWindow, autoUpdater, dialog } from 'electron'
import { spawn, exec } from 'child_process' import { spawn, exec } from 'child_process'
import * as path from 'path' import * as path from 'path'
import * as fs from 'fs'
require('@electron/remote/main').initialize() require('@electron/remote/main').initialize()
@ -57,19 +58,24 @@ if (app.isPackaged) {
} }
function installCLI() { function installCLI() {
const symlinkPath = '/usr/local/bin/ollama'
if (fs.existsSync(symlinkPath) && fs.readlinkSync(symlinkPath) === ollama) {
return
}
dialog dialog
.showMessageBox({ .showMessageBox({
type: 'info', type: 'info',
title: 'Ollama CLI installation', title: 'Ollama CLI installation',
message: 'To install the ollama CLI, we need your permission. You will be prompted to confirm.', message: 'To install the Ollama CLI, we need to ask you for administrator privileges.',
buttons: ['OK'], buttons: ['OK'],
}) })
.then(result => { .then(result => {
if (result.response === 0) { if (result.response === 0) {
let command = ` let command = `
do shell script "ln -F -s ${ollama} /usr/local/bin/ollama" with administrator privileges do shell script "ln -F -s ${ollama} /usr/local/bin/ollama" with administrator privileges
` `
exec(`osascript -e '${command}'`, (error: Error | null, stdout: string, stderr: string) => { exec(`osascript -e '${command}'`, (error: Error | null, stdout: string, stderr: string) => {
if (error) { if (error) {
console.error(`exec error: ${error}`) console.error(`exec error: ${error}`)