21 lines
770 B
PowerShell
21 lines
770 B
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$root = 'apps/game_server/src/behavior_tree'
|
|
$changed = 0
|
|
Get-ChildItem $root -Recurse -Filter *.erl | ForEach-Object {
|
|
$path = $_.FullName
|
|
$text = [IO.File]::ReadAllText($path)
|
|
if ($text -notmatch '-include\("bt_game\.hrl"\)\.' -and
|
|
($text -match '\btree_node\(\)' -or $text -match '#tree_node\{' -or $text -match '\bblackboard\(\)' -or $text -match '\bbt_status\(\)')) {
|
|
$rx = [regex]::new('(^-module\([^)]+\)\.\s*)', [Text.RegularExpressions.RegexOptions]::Multiline)
|
|
$new = $rx.Replace($text, "`$1`r`n-include(`"bt_game.hrl`").`r`n", 1)
|
|
if ($new -ne $text) {
|
|
if ($_.IsReadOnly) { $_.IsReadOnly = $false }
|
|
[IO.File]::WriteAllText($path, $new)
|
|
$changed++
|
|
}
|
|
}
|
|
}
|
|
|
|
"changed_files=$changed"
|