openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
scripts/Update-Snippets.ps1
23lines · modeblame
18425c24Jesse Squire1 years ago | 1 | [CmdletBinding()] |
| 2 | param( | |
| 3 | [string]$Path | |
| 4 | ) | |
| 5 | | |
dd729c12Jesse Squire7 months ago | 6 | # If this is not a real path, use the git root so the tool can find both |
| 7 | # the snippet source files (in /tests) and the markdown files (README.md at root). | |
18425c24Jesse Squire1 years ago | 8 | if (-not $Path) { |
| 9 | $_gitRoot = git rev-parse --show-toplevel 2>$null | |
| 10 | | |
| 11 | if ((-not $_gitRoot) -or ($LASTEXITCODE -ne 0)) { | |
| 12 | Write-Error "Could not determine the git root directory. Please specify the path to the project file." | |
| 13 | exit 1 | |
| 14 | } | |
| 15 | | |
dd729c12Jesse Squire7 months ago | 16 | $Path = (Resolve-Path -LiteralPath $_gitRoot).Path |
18425c24Jesse Squire1 years ago | 17 | } |
| 18 | | |
| 19 | # Update snippets | |
| 20 | Write-Host "Updating snippets in $Path" | |
| 21 | | |
| 22 | dotnet tool restore | |
| 23 | dotnet tool run snippet-generator -b $Path |