@@ -2,7 +2,7 @@ import { ipcMain, BrowserWindow, shell } from 'electron';
22import * as fs from 'fs/promises' ;
33import * as path from 'path' ;
44import * as os from 'os' ;
5- import { exec } from 'child_process' ;
5+
66import {
77 getKeyList ,
88 getCurrentKey ,
@@ -365,15 +365,19 @@ Droid instructions here.
365365 await shell . openPath ( filePath ) ;
366366 } ) ;
367367
368- // dk CLI check
368+ // dk CLI check - check file directly for faster detection
369369 ipcMain . handle ( 'dk:check' , async ( ) : Promise < { installed : boolean ; installCmd : string ; platform : string } > => {
370370 const platform = os . platform ( ) ;
371- const cmd = platform === 'win32'
372- ? 'powershell -NoProfile -Command "if (Get-Command dk -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"'
373- : 'which dk' ;
374- const installed = await new Promise < boolean > ( ( resolve ) => {
375- exec ( cmd , ( error ) => resolve ( ! error ) ) ;
376- } ) ;
371+ const dkPath = platform === 'win32'
372+ ? path . join ( process . env . LOCALAPPDATA || path . join ( os . homedir ( ) , 'AppData' , 'Local' ) , 'oroio' , 'bin' , 'dk.ps1' )
373+ : path . join ( os . homedir ( ) , '.local' , 'bin' , 'dk' ) ;
374+ let installed = false ;
375+ try {
376+ await fs . access ( dkPath ) ;
377+ installed = true ;
378+ } catch {
379+ // file not found
380+ }
377381 const installCmd = platform === 'win32'
378382 ? 'irm https://raw.githubusercontent.com/notdp/oroio/main/install.ps1 | iex'
379383 : 'curl -fsSL https://raw.githubusercontent.com/notdp/oroio/main/install.sh | bash' ;
0 commit comments