Permalink
Browse files

#260 - Have build scripts report on files with trailing spaces

  • Loading branch information...
1 parent cb6d2c3 commit a1cb6dfbb8aebac4e4e98a0bd05f623190ce7634 @mbest mbest committed Feb 27, 2012
Showing with 45 additions and 13 deletions.
  1. +16 −1 build/build-linux
  2. +29 −12 build/build-windows.bat
View
@@ -1,10 +1,25 @@
#!/bin/sh
+# 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
+cd build
+if [ -s $OutTrailingSpaceListFile ]
+then
+ echo "The following files have trailing spaces that need to be cleaned up:"
+ echo ""
+ cat $OutTrailingSpaceListFile
+ echo ""
+else
+ rm $OutTrailingSpaceListFile
+fi
+
OutDebugFile='output/knockout-latest.debug.js'
OutMinFile='output/knockout-latest.js'
# Combine the source files
-SourceFiles=`grep js < fragments/source-references.js | # Find JS references
+SourceFiles=`grep js < fragments/source-references.js | # Find JS references
sed "s/[ \',]//g" | # Strip off JSON fluff (whitespace, commas, quotes)
sed -e 's/.*/..\/&/' | # Fix the paths by prefixing with ../
tr '\n' ' '` # Combine into single line
View
@@ -1,41 +1,58 @@
-@echo off
+@echo off
+
+@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
+rm %OutTrailingSpaceListFile%
+goto :TrailingSpaceOkay
+
+:NeedFixTrailingSpace
+echo The following files have trailing spaces that need to be cleaned up:
+echo.
+type %OutTrailingSpaceListFile%
+echo.
+
+:TrailingSpaceOkay
set OutDebugFile=output\knockout-latest.debug.js
set OutMinFile=output\knockout-latest.js
set AllFiles=
-for /f "eol=] skip=1 delims=' " %%i in (fragments\source-references.js) do set Filename=%%i& call :Concatenate
+for /f "eol=] skip=1 delims=' " %%i in (fragments\source-references.js) do set Filename=%%i& call :Concatenate
goto :Combine
-:Concatenate
- if /i "%AllFiles%"=="" (
+:Concatenate
+ if /i "%AllFiles%"=="" (
set AllFiles=..\%Filename:/=\%
- ) else (
+ ) else (
set AllFiles=%AllFiles% ..\%Filename:/=\%
- )
-goto :EOF
+ )
+goto :EOF
:Combine
type fragments\amd-pre.js > %OutDebugFile%.temp
-type %AllFiles% >> %OutDebugFile%.temp
+type %AllFiles% >> %OutDebugFile%.temp 2>nul
type fragments\amd-post.js >> %OutDebugFile%.temp
@rem Now call Google Closure Compiler to produce a minified version
tools\curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode "js_code=/**@const*/var DEBUG=false;" --data-urlencode js_code@%OutDebugFile%.temp "http://closure-compiler.appspot.com/compile" > %OutMinFile%.temp
@rem Finalise each file by prefixing with version header and surrounding in function closure
-copy /y fragments\version-header.js %OutDebugFile%
+copy /y fragments\version-header.js %OutDebugFile% >nul
echo (function(window,document,navigator,undefined){>> %OutDebugFile%
echo var DEBUG=true;>> %OutDebugFile%
type %OutDebugFile%.temp >> %OutDebugFile%
echo })(window,document,navigator);>> %OutDebugFile%
del %OutDebugFile%.temp
-copy /y fragments\version-header.js %OutMinFile%
+copy /y fragments\version-header.js %OutMinFile% >nul
echo (function(window,document,navigator,undefined){>> %OutMinFile%
type %OutMinFile%.temp >> %OutMinFile%
echo })(window,document,navigator);>> %OutMinFile%
del %OutMinFile%.temp
@rem Inject the version number string
set /p Version= <fragments\version.txt
-cscript tools\searchReplace.js "##VERSION##" %VERSION% %OutDebugFile% %OutMinFile%
-cscript tools\searchReplace.js "\r\n" "\n" %OutDebugFile% %OutMinFile%
+cscript tools\searchReplace.js "##VERSION##" %VERSION% %OutDebugFile% %OutMinFile% >nul
+cscript tools\searchReplace.js "\r\n" "\n" %OutDebugFile% %OutMinFile% >nul

0 comments on commit a1cb6df

Please sign in to comment.