Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
08b933cc
Commit
08b933cc
authored
Jul 16, 2023
by
Jeffrey Morgan
Browse files
app: use `async` and `await instead of callbacks
parent
6746a00a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
app/src/app.tsx
app/src/app.tsx
+15
-20
No files found.
app/src/app.tsx
View file @
08b933cc
import
{
useState
}
from
'
react
'
import
{
useState
}
from
'
react
'
import
copy
from
'
copy-to-clipboard
'
import
copy
from
'
copy-to-clipboard
'
import
{
exec
}
from
'
child_process
'
import
{
exec
as
cbExec
}
from
'
child_process
'
import
*
as
path
from
'
path
'
import
*
as
path
from
'
path
'
import
*
as
fs
from
'
fs
'
import
*
as
fs
from
'
fs
'
import
{
DocumentDuplicateIcon
}
from
'
@heroicons/react/24/outline
'
import
{
DocumentDuplicateIcon
}
from
'
@heroicons/react/24/outline
'
import
{
app
}
from
'
@electron/remote
'
import
{
app
}
from
'
@electron/remote
'
import
OllamaIcon
from
'
./ollama.svg
'
import
OllamaIcon
from
'
./ollama.svg
'
import
{
promisify
}
from
'
util
'
const
ollama
=
app
.
isPackaged
?
path
.
join
(
process
.
resourcesPath
,
'
ollama
'
)
:
path
.
resolve
(
process
.
cwd
(),
'
..
'
,
'
ollama
'
)
const
ollama
=
app
.
isPackaged
?
path
.
join
(
process
.
resourcesPath
,
'
ollama
'
)
:
path
.
resolve
(
process
.
cwd
(),
'
..
'
,
'
ollama
'
)
const
exec
=
promisify
(
cbExec
)
async
function
installCLI
(
callback
:
()
=>
void
)
{
async
function
installCLI
()
{
const
symlinkPath
=
'
/usr/local/bin/ollama
'
const
symlinkPath
=
'
/usr/local/bin/ollama
'
if
(
fs
.
existsSync
(
symlinkPath
)
&&
fs
.
readlinkSync
(
symlinkPath
)
===
ollama
)
{
if
(
fs
.
existsSync
(
symlinkPath
)
&&
fs
.
readlinkSync
(
symlinkPath
)
===
ollama
)
{
callback
&&
callback
()
return
return
}
}
const
command
=
`
const
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
)
=>
{
if
(
error
)
{
console
.
error
(
`cli: failed to install cli:
${
error
.
message
}
`
)
callback
&&
callback
()
return
}
callback
&&
callback
()
try
{
})
await
exec
(
`osascript -e '
${
command
}
'`
)
}
catch
(
error
)
{
console
.
error
(
`cli: failed to install cli:
${
error
.
message
}
`
)
return
}
}
}
export
default
function
()
{
export
default
function
()
{
...
@@ -66,12 +63,10 @@ export default function () {
...
@@ -66,12 +63,10 @@ export default function () {
<
pre
className
=
'mx-auto text-4xl text-gray-400'
>
>
ollama
</
pre
>
<
pre
className
=
'mx-auto text-4xl text-gray-400'
>
>
ollama
</
pre
>
<
div
className
=
'mx-auto'
>
<
div
className
=
'mx-auto'
>
<
button
<
button
onClick
=
{
()
=>
{
onClick
=
{
async
()
=>
{
// install the command line
await
installCLI
()
installCLI
(()
=>
{
window
.
focus
()
window
.
focus
()
setStep
(
2
)
setStep
(
2
)
})
}
}
}
}
className
=
'rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
className
=
'rounded-dm mx-auto w-[60%] rounded-md bg-black px-4 py-2 text-sm text-white hover:brightness-110'
>
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment