@@ -136,6 +136,14 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
136136 yield * command . uninstall ;
137137 expect ( yield * fs . readFileString ( theirs ) ) . toBe ( "npm's t3\n" ) ;
138138 expect ( yield * fs . readLink ( path . join ( home , "bin" , "t3" ) ) ) . toBe ( path . join ( home , "gone" ) ) ;
139+
140+ const launcher = path . join ( home , ".t3" , "bin" , "t3" ) ;
141+ yield * fs . writeFileString ( launcher , "npm's t3\n" ) ;
142+ process . env . PATH = path . dirname ( launcher ) ;
143+ expect ( yield * command . state ) . toMatchObject ( { onPath : false , shadowedBy : launcher } ) ;
144+ expect ( ( yield * Effect . flip ( command . install ) ) . message ) . toContain ( "Could not set up" ) ;
145+ yield * command . uninstall ;
146+ expect ( yield * fs . readFileString ( launcher ) ) . toBe ( "npm's t3\n" ) ;
139147 } ) . pipe ( Effect . scoped ) ,
140148 ) ;
141149
@@ -217,6 +225,34 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
217225 } ) . pipe ( Effect . scoped ) ,
218226 ) ;
219227
228+ it . effect ( "does not treat its own launcher as another t3 when its folder is first on PATH" , ( ) =>
229+ Effect . gen ( function * ( ) {
230+ const fs = yield * FileSystem . FileSystem ;
231+ const path = yield * Path . Path ;
232+ const home = yield * fs . makeTempDirectoryScoped ( ) ;
233+ const launcher = path . join ( home , ".t3" , "bin" , "t3" ) ;
234+ process . env . PATH = [ path . dirname ( launcher ) , path . join ( home , ".local" , "bin" ) ] . join ( ":" ) ;
235+
236+ const command = yield * commandIn ( { home } ) ;
237+ const installed = yield * command . install ;
238+
239+ expect ( yield * fs . exists ( launcher ) ) . toBe ( true ) ;
240+ expect ( installed ) . toMatchObject ( {
241+ onPath : true ,
242+ installedPath : path . join ( home , ".local" , "bin" , "t3" ) ,
243+ } ) ;
244+ expect ( installed . shadowedBy ) . toBeUndefined ( ) ;
245+ expect ( yield * command . state ) . toEqual ( installed ) ;
246+
247+ const removed = yield * command . uninstall ;
248+ expect ( removed . installedPath ) . toBeNull ( ) ;
249+ expect ( removed . onPath ) . toBe ( true ) ;
250+ expect ( yield * command . state ) . toEqual ( removed ) ;
251+ expect ( yield * fs . exists ( installed . installedPath ! ) ) . toBe ( false ) ;
252+ expect ( yield * fs . exists ( launcher ) ) . toBe ( true ) ;
253+ } ) . pipe ( Effect . scoped ) ,
254+ ) ;
255+
220256 it . effect ( "leaves the Windows PATH alone when it cannot be read" , ( ) =>
221257 Effect . gen ( function * ( ) {
222258 const fs = yield * FileSystem . FileSystem ;
0 commit comments