@@ -186,6 +186,43 @@ function Resolve-NativeExecutable {
186186 return [pscustomobject ]@ { FilePath = $exePath ; Prefix = $prefix }
187187}
188188
189+ <#
190+ . SYNOPSIS
191+ Resolves the apiops CLI entrypoint from repository build output.
192+
193+ . OUTPUTS
194+ System.Management.Automation.PSCustomObject
195+ #>
196+ function Resolve-ApiopsInvocation {
197+ $moduleDir = Split-Path - Parent $PSCommandPath
198+ $repoRoot = $null
199+ $cursor = $moduleDir
200+
201+ while (-not [string ]::IsNullOrWhiteSpace($cursor )) {
202+ if (Test-Path (Join-Path $cursor ' package.json' )) {
203+ $repoRoot = $cursor
204+ break
205+ }
206+
207+ $parent = Split-Path - Parent $cursor
208+ if ($parent -eq $cursor ) {
209+ break
210+ }
211+ $cursor = $parent
212+ }
213+
214+ if ([string ]::IsNullOrWhiteSpace($repoRoot )) {
215+ throw ' Could not locate repository root from LogMasking module path.'
216+ }
217+
218+ $distCliPath = Join-Path $repoRoot ' dist/cli/index.js'
219+ if (-not (Test-Path $distCliPath )) {
220+ throw " apiops CLI entrypoint not found: $distCliPath . Run 'npm run build' from repository root."
221+ }
222+
223+ return [pscustomobject ]@ { FilePath = ' node' ; Prefix = @ ($distCliPath ) }
224+ }
225+
189226<#
190227. SYNOPSIS
191228Runs a process and streams masked output.
@@ -326,8 +363,9 @@ function Invoke-MaskedApiopsCommand {
326363 [hashtable ]$Replacements
327364 )
328365
329- Invoke-MaskedProcess - FilePath ' npx' `
330- - Arguments (@ (' apiops' ) + $Arguments ) `
366+ $apiops = Resolve-ApiopsInvocation
367+ Invoke-MaskedProcess - FilePath $apiops.FilePath `
368+ - Arguments (@ ($apiops.Prefix ) + $Arguments ) `
331369 - Replacements $Replacements
332370
333371 return $LASTEXITCODE
@@ -366,6 +404,7 @@ Export-ModuleMember -Function `
366404 Protect-ApimName , `
367405 Protect-LogLine , `
368406 Resolve-NativeExecutable , `
407+ Resolve-ApiopsInvocation , `
369408 Invoke-MaskedProcess , `
370409 Invoke-MaskedApiopsCommand , `
371410 Invoke-MaskedAzCommand
0 commit comments