@@ -119,6 +119,12 @@ describe("ElectronApp", () => {
119119 { platform : "linux" , APPIMAGE : " " , packaged : true } ,
120120 { platform : "linux" , APPIMAGE : "/tmp/app.AppImage" , packaged : false } ,
121121 { platform : "darwin" , APPIMAGE : "/tmp/app.AppImage" , packaged : true } ,
122+ {
123+ platform : "linux" ,
124+ APPIMAGE : "/tmp/other.AppImage" ,
125+ packaged : true ,
126+ executablePath : "/tmp/mount-other/t3code" ,
127+ } ,
122128 ] as const ) ( "keeps native relaunch outside packaged AppImages: %j" , ( input ) => {
123129 isPackagedMock . mockReturnValue ( input . packaged ) ;
124130 return Effect . gen ( function * ( ) {
@@ -130,7 +136,14 @@ describe("ElectronApp", () => {
130136 } ) . pipe (
131137 Effect . provide ( electronAppLayer ) ,
132138 Effect . provideService ( HostProcess . Platform , input . platform ) ,
133- Effect . provideService ( HostProcess . Environment , { APPIMAGE : input . APPIMAGE } ) ,
139+ Effect . provideService ( HostProcess . Environment , {
140+ APPIMAGE : input . APPIMAGE ,
141+ APPDIR : "/tmp/mount" ,
142+ } ) ,
143+ Effect . provideService (
144+ HostProcess . ExecutablePath ,
145+ "executablePath" in input ? input . executablePath : "/tmp/mount/t3code" ,
146+ ) ,
134147 ) ;
135148 } ) ;
136149
@@ -144,10 +157,10 @@ describe("ElectronApp", () => {
144157 const output = path . join ( directory , "result" ) ;
145158 const startup = path . join ( directory , "startup" ) ;
146159 const startupMarker = path . join ( directory , "startup-ran" ) ;
147- yield * fs . writeFileString ( startup , `printf ran > "${ startupMarker } "\nexec </dev/null\n` ) ;
160+ yield * fs . writeFileString ( startup , `printf ran >> "${ startupMarker } "\nexec </dev/null\n` ) ;
148161 yield * fs . writeFileString (
149162 launcher ,
150- '#!/bin/sh \nif [ -e /proc/self/fd/3 ] || [ -e /proc/self/fd/65 ]; then exit 65; fi\nif [ -n "$BASH_ENV$ENV" ]; then exit 66; fi\nprintf "%s\\n " "$@" > "$1"\n' ,
163+ '#!/usr/ bin/env bash \nif [ -e /proc/self/fd/3 ] || [ -e /proc/self/fd/65 ]; then exit 65; fi\nprintf "%s\\n" "$BASH_ENV" "$ENV " "$@" > "$1"\n' ,
151164 ) ;
152165 yield * fs . chmod ( launcher , 0o700 ) ;
153166 let command : ChildProcess . StandardCommand | undefined ;
@@ -181,11 +194,16 @@ describe("ElectronApp", () => {
181194 Effect . provide ( ElectronApp . layer ) ,
182195 Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , recordingSpawner ) ,
183196 Effect . provideService ( HostProcess . Platform , "linux" ) ,
197+ Effect . provideService ( HostProcess . ExecutablePath , path . join ( directory , "mount" , "t3code" ) ) ,
184198 Effect . provideService ( HostProcess . Environment , {
199+ ...process . env ,
185200 APPIMAGE : launcher ,
201+ APPDIR : path . join ( directory , "mount" ) ,
186202 BASH_ENV : startup ,
187203 ENV : startup ,
188- PATH : process . env . PATH ,
204+ SHELLOPTS : "braceexpand:hashall:interactive-comments" ,
205+ // Node uses a socket for stdin; skip Bash's remote-shell startup heuristic.
206+ SHLVL : "1" ,
189207 } ) ,
190208 ) ;
191209 assert . equal ( relaunchMock . mock . calls . length , 0 ) ;
@@ -194,7 +212,6 @@ describe("ElectronApp", () => {
194212 const waiting = yield * spawner . spawn (
195213 ChildProcess . make ( command ! . command , command ! . args , {
196214 ...command ! . options ,
197- env : command ! . options . env ?? { ...process . env , BASH_ENV : startup } ,
198215 detached : false ,
199216 additionalFds : { fd3 : { type : "output" } , fd65 : { type : "output" } } ,
200217 } ) ,
@@ -204,10 +221,11 @@ describe("ElectronApp", () => {
204221 // Closing the parent-owned pipe stands in for parent exit, without a PID poll.
205222 yield * Stream . run ( Stream . empty , waiting . stdin ) ;
206223 assert . equal ( yield * waiting . exitCode , 0 ) ;
207- assert . isFalse ( yield * fs . exists ( startupMarker ) ) ;
224+ // Only the replacement may source startup files, after the parent-exit wait.
225+ assert . equal ( yield * fs . readFileString ( startupMarker ) , "ran" ) ;
208226 assert . equal (
209227 yield * fs . readFileString ( output ) ,
210- `${ output } \ntwo words\n$HOME\n(Nightly)\n trailing \n` ,
228+ `${ startup } \n ${ startup } \n ${ output } \ntwo words\n$HOME\n(Nightly)\n trailing \n` ,
211229 ) ;
212230 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
213231 ) ;
@@ -223,7 +241,11 @@ describe("ElectronApp", () => {
223241 } ) . pipe (
224242 Effect . provide ( ElectronApp . layer ) ,
225243 Effect . provideService ( HostProcess . Platform , "linux" ) ,
226- Effect . provideService ( HostProcess . Environment , { APPIMAGE : "/tmp/app.AppImage" } ) ,
244+ Effect . provideService ( HostProcess . Environment , {
245+ APPIMAGE : "/tmp/app.AppImage" ,
246+ APPDIR : "/tmp/mount" ,
247+ } ) ,
248+ Effect . provideService ( HostProcess . ExecutablePath , "/tmp/mount/t3code" ) ,
227249 Effect . provideService (
228250 ChildProcessSpawner . ChildProcessSpawner ,
229251 ChildProcessSpawner . make ( ( ) =>
0 commit comments