@@ -6,7 +6,7 @@ import * as Schema from "effect/Schema";
66
77import type { ServerInstallation } from "@t3tools/contracts" ;
88import * as HostProcess from "@t3tools/shared/HostProcess" ;
9- import { isCommandAvailable } from "@t3tools/shared/shell" ;
9+ import { resolveCommandPath } from "@t3tools/shared/shell" ;
1010
1111import packageJson from "../../package.json" with { type : "json" } ;
1212
@@ -143,7 +143,7 @@ const resolveInstallLauncher = Effect.gen(function* () {
143143} ) ;
144144
145145/**
146- * Uses `t3` on PATH, the originating package runner, or this install's absolute launcher path.
146+ * Uses this install's `t3` on PATH, the originating runner, or its absolute launcher path.
147147 * Arguments are quoted for POSIX shells or PowerShell on Windows.
148148 */
149149export const resolveHostCliCommand = Effect . fn ( "invocation.resolveHostCliCommand" ) ( function * (
@@ -155,7 +155,16 @@ export const resolveHostCliCommand = Effect.fn("invocation.resolveHostCliCommand
155155 [ prefix , ...args . map ( ( arg ) => hostShellWord ( platform , arg ) ) ] . join ( " " ) ;
156156 const command = yield * resolveCliCommand ( subcommand ) ;
157157 if ( command !== `t3 ${ subcommand } ` ) return { command : withArgs ( command ) , launcher : false } ;
158- if ( yield * isCommandAvailable ( "t3" ) ) return { command : withArgs ( command ) , launcher : false } ;
158+ const onPath = yield * resolveCommandPath ( "t3" ) ;
159+ if ( onPath !== null ) {
160+ const shim = ( yield * HostProcess . Environment ) . T3CODE_CLI_PATH ?. trim ( ) ;
161+ const fs = yield * FileSystem . FileSystem ;
162+ const real = ( file : string ) => fs . realPath ( file ) . pipe ( Effect . orElseSucceed ( ( ) => null ) ) ;
163+ const shimReal = shim ? yield * real ( shim ) : null ;
164+ if ( shimReal === null || shimReal === ( yield * real ( onPath ) ) ) {
165+ return { command : withArgs ( command ) , launcher : false } ;
166+ }
167+ }
159168 const launcher = yield * resolveInstallLauncher ;
160169 if ( Option . isNone ( launcher ) ) return { command : withArgs ( command ) , launcher : false } ;
161170 // PowerShell runs a quoted path only through the call operator.
0 commit comments