@@ -32,16 +32,49 @@ const CLI_BIN_PATH = join(CLI_BIN_DIR, process.platform === "win32" ? "executor.
3232// CLI install — copy sidecar to ~/.executor/bin and patch shell PATH
3333// ---------------------------------------------------------------------------
3434
35+ const getInstalledCliVersion = ( ) : string | null => {
36+ if ( ! existsSync ( CLI_BIN_PATH ) ) return null ;
37+ try {
38+ const { execFileSync } = require ( "node:child_process" ) as typeof import ( "node:child_process" ) ;
39+ return execFileSync ( CLI_BIN_PATH , [ "--version" ] , {
40+ timeout : 5000 ,
41+ encoding : "utf-8" ,
42+ } ) . trim ( ) ;
43+ } catch {
44+ return null ;
45+ }
46+ } ;
47+
3548const installCli = ( ) : void => {
3649 if ( isDev ) return ;
3750
3851 const sidecar = join ( process . resourcesPath , binaryName ) ;
3952 if ( ! existsSync ( sidecar ) ) return ;
4053
54+ // Check if installed version is already same or newer
55+ const appVersion = app . getVersion ( ) ;
56+ const installedVersion = getInstalledCliVersion ( ) ;
57+ if ( installedVersion ) {
58+ const parse = ( v : string ) => v . replace ( / ^ v / , "" ) . split ( / [ . - ] / ) . map ( ( s ) => {
59+ const n = parseInt ( s , 10 ) ;
60+ return isNaN ( n ) ? 0 : n ;
61+ } ) ;
62+ const installed = parse ( installedVersion ) ;
63+ const bundled = parse ( appVersion ) ;
64+ const len = Math . max ( installed . length , bundled . length ) ;
65+ let cmp = 0 ;
66+ for ( let i = 0 ; i < len && cmp === 0 ; i ++ ) {
67+ cmp = ( installed [ i ] ?? 0 ) - ( bundled [ i ] ?? 0 ) ;
68+ }
69+ if ( cmp >= 0 ) return ; // Already up to date or newer
70+ }
71+
4172 // Copy binary
4273 mkdirSync ( CLI_BIN_DIR , { recursive : true } ) ;
4374 copyFileSync ( sidecar , CLI_BIN_PATH ) ;
4475 try { chmodSync ( CLI_BIN_PATH , 0o755 ) ; } catch { }
76+ console . log ( `Installed executor CLI ${ appVersion } to ${ CLI_BIN_PATH } ` +
77+ ( installedVersion ? ` (was ${ installedVersion } )` : "" ) ) ;
4578
4679 // Copy WASM if present
4780 const wasm = join ( process . resourcesPath , "emscripten-module.wasm" ) ;
0 commit comments