forked from knockout/knockout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/260-trailing-white-space'
- Loading branch information
Showing
55 changed files
with
907 additions
and
841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,53 @@ | ||
@echo off | ||
@echo off | ||
|
||
call tools/check-trailing-space-windows.bat | ||
if %errorlevel% NEQ 0 goto Fail | ||
|
||
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 | ||
|
||
echo. | ||
echo Build succeeded | ||
exit /b 0 | ||
|
||
:Fail | ||
echo. | ||
echo Build failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
# Check that all files have trailing spaces stripped | ||
OutTrailingSpaceListFile='output/knockout-files-to-clean.txt' | ||
cd .. | ||
grep -nrI '[ ]$' `find * | grep -E "\.(js|html|css|bat|ps1)$"` | grep -v "^build/output/" > build/$OutTrailingSpaceListFile | ||
cd build | ||
if [ -s $OutTrailingSpaceListFile ] | ||
then | ||
echo "The following files have trailing spaces that need to be cleaned up:" | ||
echo "" | ||
cat $OutTrailingSpaceListFile | ||
rm $OutTrailingSpaceListFile | ||
exit 1 | ||
fi | ||
rm $OutTrailingSpaceListFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@echo off | ||
|
||
@rem Check that all files have trailing spaces stripped | ||
set OutTrailingSpaceListFile=output\knockout-files-to-clean.txt | ||
cd .. | ||
findstr -nrs -c:"[ ]$" *.js *.html *.css *.bat *.ps1 | findstr -rv "^build\\output" > 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% | ||
del %OutTrailingSpaceListFile% | ||
exit /b 1 | ||
|
||
:TrailingSpaceOkay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# If needed, first run: Set-ExecutionPolicy Unrestricted | ||
|
||
$allFiles = (Get-ChildItem -Path ..\..\ -Include *.js,*.css,*.bat,*.html -Recurse) | ||
|
||
$allFiles | %{ | ||
# Read file, remove trailing spaces/tabs, output back to file in CP1252 format (default for Git on Windows) | ||
# This will also ensure the file has a trailing linebreak | ||
Write-Host "Processing $_..." | ||
$fileContent = (Get-Content $_) -replace "[ \t]+$", "" | ||
[System.IO.File]::WriteAllLines($_, $fileContent, [System.Text.Encoding]::GetEncoding(1252)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.