Skip to content

Commit

Permalink
Build scripts should allow lines that are purely whitespace (but not …
Browse files Browse the repository at this point in the history
…non-whitespace with trailing whitespace)
  • Loading branch information
SteveSanderson committed Apr 13, 2012
1 parent e33ad22 commit ac96a71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/tools/check-trailing-space-linux
Expand Up @@ -3,7 +3,7 @@
# Check that all files have trailing spaces stripped
OutTrailingSpaceListFile='output/knockout-files-to-clean.txt'
cd ..
grep -rl ' $' build spec src | grep -v ".exe$" > build/$OutTrailingSpaceListFile
grep -nrI '[^ ][ ]\+$' * | grep -rv "^build/output/" > build/$OutTrailingSpaceListFile
cd build
if [ -s $OutTrailingSpaceListFile ]
then
Expand Down
22 changes: 11 additions & 11 deletions build/tools/check-trailing-space-windows.bat
Expand Up @@ -3,17 +3,17 @@
@rem Check that all files have trailing spaces stripped
set OutTrailingSpaceListFile=output\knockout-files-to-clean.txt
cd ..
findstr -rsm -c:" $" * |findstr -rv "^.git" |findstr -rv ".exe$" > build\%OutTrailingSpaceListFile%
cd build
for %%R in (%OutTrailingSpaceListFile%) do if %%~zR gtr 0 goto :NeedFixTrailingSpace
del %OutTrailingSpaceListFile%
goto :TrailingSpaceOkay

:NeedFixTrailingSpace
echo The following files have trailing spaces that need to be cleaned up:
echo.
type %OutTrailingSpaceListFile%
@rem Totally outlandish way to detect trailing whitespace on non-whitespace-only lines, because the DOS "findstr" command can't handle spaces in regexes.
@rem We should consider changing the whole Windows build script to PowerShell, where this would be trivial and clean.
set foundTrailingWhitespace=0
findstr -rsen -c:" " *.js *.html *.css *.bat *.ps1 > build\%OutTrailingSpaceListFile%
cscript build\tools\searchReplace.js " {2,}" "" build\%OutTrailingSpaceListFile% >nul
for /f "tokens=1,2,* delims=:" %%i in (build\%OutTrailingSpaceListFile%) do @if "%%k" NEQ "" (
echo Error: Trailing whitespace on %%i line %%j
set foundTrailingWhitespace=1
)
cd build
del %OutTrailingSpaceListFile%
exit /b 1

:TrailingSpaceOkay
if %foundTrailingWhitespace% EQU 1 exit /b 1

0 comments on commit ac96a71

Please sign in to comment.