From a1fcd849603f57f6ef15fbaacb66bb313eceba23 Mon Sep 17 00:00:00 2001 From: m-nash Date: Mon, 30 Jan 2023 11:02:16 -0800 Subject: [PATCH] updates to make scripts more generic --- eng/common/scripts/Cadl-Project-Generate.ps1 | 11 ++++++++--- eng/common/scripts/Cadl-Project-Sync.ps1 | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/eng/common/scripts/Cadl-Project-Generate.ps1 b/eng/common/scripts/Cadl-Project-Generate.ps1 index 40f3fcc2f40e..fa2b72c75bef 100644 --- a/eng/common/scripts/Cadl-Project-Generate.ps1 +++ b/eng/common/scripts/Cadl-Project-Generate.ps1 @@ -49,6 +49,7 @@ function NpmInstallForProject([string]$workingDirectory) { } } +$resolvedProjectDirectory = Resolve-Path $ProjectDirectory $emitterName = &$GetEmitterNameFn $cadlConfigurationFile = Resolve-Path "$ProjectDirectory/cadl-location.yaml" @@ -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 } } diff --git a/eng/common/scripts/Cadl-Project-Sync.ps1 b/eng/common/scripts/Cadl-Project-Sync.ps1 index 98e8f6c0e062..21f63403c68d 100644 --- a/eng/common/scripts/Cadl-Project-Sync.ps1 +++ b/eng/common/scripts/Cadl-Project-Sync.ps1 @@ -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 } }