move the cleanup config to -SaveInputs parameter on the cli (#4646)

Co-authored-by: m-nash <prognash@gmail.com>
This commit is contained in:
Azure SDK Bot 2023-05-22 14:18:52 -07:00 committed by GitHub
parent b32fccd303
commit b8e6aa1fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,8 @@ param (
[Parameter(Position=0)]
[ValidateNotNullOrEmpty()]
[string] $ProjectDirectory,
[Parameter(Position=1)]
[string] $typespecAdditionalOptions ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2
[string] $TypespecAdditionalOptions = $null, ## addtional typespec emitter options, separated by semicolon if more than one, e.g. option1=value1;option2=value2
[switch] $SaveInputs = $false ## saves the temporary files during execution, default false
)
$ErrorActionPreference = "Stop"
@ -80,12 +80,17 @@ try {
}
}
$typespecCompileCommand = "npx tsp compile $mainTypeSpecFile --emit $emitterName$emitterAdditionalOptions"
if ($typespecAdditionalOptions) {
$options = $typespecAdditionalOptions.Split(";");
if ($TypespecAdditionalOptions) {
$options = $TypespecAdditionalOptions.Split(";");
foreach ($option in $options) {
$typespecCompileCommand += " --option $emitterName.$option"
}
}
if ($SaveInputs) {
$typespecCompileCommand += " --option $emitterName.save-inputs=true"
}
Write-Host($typespecCompileCommand)
Invoke-Expression $typespecCompileCommand
@ -95,7 +100,7 @@ finally {
Pop-Location
}
$shouldCleanUp = $configuration["cleanup"] ?? $true
$shouldCleanUp = !$SaveInputs
if ($shouldCleanUp) {
Remove-Item $tempFolder -Recurse -Force
}