0

I am working with azure devops with salesforce. My query is :- I wrote a powershell script by which if anyone do changes in any single file inside aura component or LWC component folders , the script will bring the whole folder and do the validation. I cannot able to write the logic by which it will bring the folder , the moment we do changes in a file inside the folder of aura or LWC.

My code looks like below :-

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 latest 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 ".js" -or $extn -eq ".cmp"-or $extn -eq "../src/aura" -or $extn -eq ".css" -or $extn -eq ".js-meta.xml")
    {
        echo "inside meta"
        $metafile = $file + "-meta.xml"
        echo FA|xcopy $metafile temp\$metafile
        echo $temp
    }
    
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.