I am writing a powershell script for my cicd devops process in azure.
my need is :- whenever a file gets changed by a developer ( which is within a folder ) , then the whole folder with all files should get copied and sit inside a temp folder.
by which i can do the build for that folder.
I am talking this scenario of salesforce aura and lwc components.
my code till now looks like below , can someone helps me to get away with this issue.
echo "Entering Powershell"
echo $env:WORKSPACE
echo "Cleaning temp directory"
#Remove-Item -recurse temp -Force | Out-Null
$files = git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD~1 HEAD
echo $files #Gives the name of file along with its path ,that has been changed, the lastest commit
echo "Re-creating temp directory"
new-item -Name "temp" -Force -ItemType directory | Out-Null
foreach($file in $files)
{
echo "printing file name"
#Replace slash
$file = $file -replace "/","\"
#Copy files to temp directory
echo FA|xcopy $file temp\$file
# echo $temp
#Check extension
$extn = [IO.Path]::GetExtension($file)
if ($extn -eq ".cls" -or $extn -eq ".page" -or $extn -eq ".trigger" -or $extn -eq ".cmp" -or $extn -eq ".email" -or $extn -eq ".resource")
{
echo "inside meta"
$metafile = $file + "-meta.xml"
echo FA|xcopy $metafile temp\$metafile
echo $temp
}
}