YarnComplete.psm1
$GetCompletion = { param($commandName, $wordToComplete, $cursorPosition) if (-not (Test-Path .\package.json)) { return } $startMatch = [Text.RegularExpressions.Regex]::Match($wordToComplete, '\s([^\s]*)') if (-not $startMatch.Success) { return } $start = $startMatch.Groups[1].Value try { $packageInfo = Get-Content -Raw -Encoding UTF8 .\package.json | ConvertFrom-Json $scripts = Get-Member -InputObject $packageInfo.scripts | ? {$_.MemberType -eq 'NoteProperty'} | Select-Object -ExpandProperty Name return $scripts | Where-Object { $_ -like "$start*" } | ForEach-Object { New-Object -Type System.Management.Automation.CompletionResult -ArgumentList @($_, $_, "ParameterValue", $_) } } catch { return } } Register-ArgumentCompleter -Native -CommandName 'yarn' -ScriptBlock $GetCompletion |