Skip to content

Commit

Permalink
updates to make scripts more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
m-nash authored and azure-sdk committed Jan 30, 2023
1 parent 4dde225 commit 1a6d790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions eng/common/scripts/Cadl-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function NpmInstallForProject([string]$workingDirectory) {
}
}

$resolvedProjectDirectory = Resolve-Path $ProjectDirectory
$emitterName = &$GetEmitterNameFn
$cadlConfigurationFile = Resolve-Path "$ProjectDirectory/cadl-location.yaml"

Expand All @@ -69,10 +70,14 @@ try {
if ($LASTEXITCODE) { exit $LASTEXITCODE }

if (Test-Path "Function:$GetEmitterAdditionalOptionsFn") {
$emitterAdditionalOptions = &$GetEmitterAdditionalOptionsFn
$emitterAdditionalOptions = &$GetEmitterAdditionalOptionsFn $resolvedProjectDirectory
if ($emitterAdditionalOptions.Length -gt 0) {
$emitterAdditionalOptions = " $emitterAdditionalOptions"
}
}
Write-Host("npx cadl compile $mainCadlFile --emit $emitterName $emitterAdditionalOptions")
npx cadl compile $mainCadlFile --emit $emitterName $emitterAdditionalOptions
$cadlCompileCommand = "npx cadl compile $mainCadlFile --emit $emitterName$emitterAdditionalOptions"
Write-Host($cadlCompileCommand)
Invoke-Expression $cadlCompileCommand

if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
Expand Down
5 changes: 3 additions & 2 deletions eng/common/scripts/Cadl-Project-Sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ function AddSparseCheckoutPath([string]$subDirectory) {

function CopySpecToProjectIfNeeded([string]$specCloneRoot, [string]$mainSpecDir, [string]$dest, [string[]]$specAdditionalSubDirectories) {
$source = "$specCloneRoot/$mainSpecDir"
Write-Host "Copying spec from $source"
Copy-Item -Path $source -Destination $dest -Recurse -Force
Write-Host "Copying spec from $source to $dest"

foreach ($additionalDir in $specAdditionalSubDirectories) {
$source = "$specCloneRoot/$additionalDir"
Write-Host "Copying spec from $source"
Write-Host "Copying spec from $source to $dest"
Copy-Item -Path $source -Destination $dest -Recurse -Force
}
}
Expand Down

0 comments on commit 1a6d790

Please sign in to comment.