Skip to content

Instantly share code, notes, and snippets.

@b-wilder
Created January 22, 2022 16:54
Show Gist options
  • Save b-wilder/839d404bd22786546257d12f48d44e03 to your computer and use it in GitHub Desktop.
Save b-wilder/839d404bd22786546257d12f48d44e03 to your computer and use it in GitHub Desktop.
Execute all apex scripts in a folder
#Loop through all .apex scripts in the directory passed to $args[0] and execute them in sequence
$path = $args[0]
Get-ChildItem $path -Filter *.apex |
Foreach-Object {
# $_ : object in loop
# $_.FullName: full path to file, including extension
# $fileName: filename and extension without path
$fileName = Split-Path -Path $_.FullName -Leaf -Resolve
sfdx force:apex:execute -f "$path\$fileName"
}
#Execute all apex scripts in the scripts\apex\postdeployment folder after deploying metadata
powershell -File .\scripts\ps\executeApexScripts.ps1 ".\scripts\apex\postdeployment"
#Execute all apex scripts in the scripts\apex\predeployment folder before deploying metadata
powershell -File .\scripts\ps\executeApexScripts.ps1 ".\scripts\apex\predeployment"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment