11diff --git a/buildifier/runner.bat.template b/buildifier/runner.bat.template
2- index 13ca3fa..d8ccac9 100644
2+ index 13ca3fa..a9a5828 100644
33--- a/buildifier/runner.bat.template
44+++ b/buildifier/runner.bat.template
5- @@ -11,9 +11,34 @@ set stripped_args=%stripped_args:'=%
5+ @@ -11,35 +11,49 @@ set stripped_args=%stripped_args:'=%
66 rem Get the absolute path to the buildifier executable
77- for /f "tokens=2" %%i in ('findstr /r "\<buildifier\.exe\>" MANIFEST') do (set buildifier_abs_path=%%i)
88+ if exist MANIFEST (
@@ -16,33 +16,65 @@ index 13ca3fa..d8ccac9 100644
1616+ for /f "tokens=2" %%i in ('findstr /r "\<buildifier\.exe\>" "%manifest_file%"') do (set buildifier_abs_path=%%i)
1717
1818 powershell ^
19+ - function Buildify($Root)^
20+ + $startTime = Get-Date;^
1921+ function Should-Exclude($Path)^
20- + {^
22+ {^
23+ - $Folder = (New-Object -Com Scripting.FileSystemObject).GetFolder($Root);^
24+ - $Files = $Folder.Files ^| Where-Object {^
25+ - $_.Name -eq 'BUILD.bazel' `^
26+ - -or $_.Name -eq 'BUILD' `^
27+ - -or $_.Name -eq 'WORKSPACE' `^
28+ - -or $_.Name -eq 'WORKSPACE.bazel' `^
29+ - -or $_.Name -eq 'WORKSPACE.oss' `^
30+ - -or $_.Name -clike '*.bzl' `^
31+ - -or $_.Name -clike '*.sky' `^
32+ - -or $_.Name -clike '*.BUILD' `^
33+ - -or $_.Name -clike 'BUILD.*.bazel' `^
34+ - -or $_.Name -clike 'BUILD.*.oss' `^
35+ - -or $_.Name -clike 'WORKSPACE.*.bazel' `^
36+ - -or $_.Name -clike 'WORKSPACE.*.oss'^
37+ - };^
38+ - foreach ($File in $Files)^
39+ - {^
40+ - ^& '%buildifier_abs_path%' %stripped_args% $File.Path;^
41+ - };^
42+ - foreach ($SubFolder in $Folder.Subfolders)^
2143+ $relPath = '.' + $Path.Substring('%BUILD_WORKSPACE_DIRECTORY%'.Length);^
2244+ foreach ($pattern in @(@@EXCLUDE_PATTERNS@@))^
23- + {^
45+ {^
46+ - $CurrentItem = Get-Item $SubFolder.Path -ErrorAction SilentlyContinue;^
47+ - if ($CurrentItem -and !$CurrentItem.Attributes.ToString().Contains('ReparsePoint'))^
2448+ if ($relPath -clike $pattern)^
25- + {^
49+ {^
50+ - Buildify($SubFolder.Path);^
51+ + Write-Host excl relPath=$relPath;^
2652+ return $true;^
27- + };^
28- + };^
53+ };^
54+ };^
55+ + Write-Host incl relPath=$relPath;^
2956+ return $false;^
3057+ };^
31- function Buildify($Root)^
32- {^
33- + if (Should-Exclude $Root)^
34- + {^
35- + return;^
36- + };^
37- $Folder = (New-Object -Com Scripting.FileSystemObject).GetFolder($Root);^
38- $Files = $Folder.Files ^| Where-Object {^
39- + (^
40- $_.Name -eq 'BUILD.bazel' `^
41- @@ -30,2 +55,3 @@ function Buildify($Root)^
42- -or $_.Name -clike 'WORKSPACE.*.oss'^
43- + ) -and -not (Should-Exclude $_.Path)^
44- };^
45- @@ -44,2 +70,2 @@ function Buildify($Root)^
58+ + $Files = Get-ChildItem -LiteralPath '%BUILD_WORKSPACE_DIRECTORY:/=\%' -Recurse -File -ErrorAction SilentlyContinue ^| Where-Object {^
59+ + (^
60+ + $_.Name -eq 'BUILD.bazel' `^
61+ + -or $_.Name -eq 'BUILD' `^
62+ + -or $_.Name -eq 'WORKSPACE' `^
63+ + -or $_.Name -eq 'WORKSPACE.bazel' `^
64+ + -or $_.Name -eq 'WORKSPACE.oss' `^
65+ + -or $_.Name -clike '*.bzl' `^
66+ + -or $_.Name -clike '*.sky' `^
67+ + -or $_.Name -clike '*.BUILD' `^
68+ + -or $_.Name -clike 'BUILD.*.bazel' `^
69+ + -or $_.Name -clike 'BUILD.*.oss' `^
70+ + -or $_.Name -clike 'WORKSPACE.*.bazel' `^
71+ + -or $_.Name -clike 'WORKSPACE.*.oss'^
72+ + ) -and -not (Should-Exclude $_.FullName)^
73+ + };^
74+ + if ($Files)^
75+ + {^
76+ + ^& '%buildifier_abs_path%' %stripped_args% $Files.FullName;^
4677 };^
4778- Buildify('%BUILD_WORKSPACE_DIRECTORY%');
48- + Buildify('%BUILD_WORKSPACE_DIRECTORY:/=\%');
79+ + $duration = (Get-Date) - $startTime;^
80+ + Write-Host ('Execution time: {0:N2} seconds' -f $duration.TotalSeconds);
0 commit comments