Skip to content

Commit

Permalink
move the cleanup config to -SaveInputs parameter on the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
m-nash authored and azure-sdk committed May 18, 2023
1 parent 2f42d4f commit 92a19d1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions eng/common/scripts/TypeSpec-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -95,7 +100,7 @@ finally {
Pop-Location
}

$shouldCleanUp = $configuration["cleanup"] ?? $true
$shouldCleanUp = !$SaveInputs
if ($shouldCleanUp) {
Remove-Item $tempFolder -Recurse -Force
}

0 comments on commit 92a19d1

Please sign in to comment.