Skip to content

Commit 4aab082

Browse files
committed
build,windows: clean lint paths in vcbuild.bat
* enable eslint to run even in a "clean" workspace * small improvement in performance by reducing number of calls to `findstr` * Document [jslint/jslint-ci] nodejs#11856 (comment)
1 parent 8fbace1 commit 4aab082

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

vcbuild.bat

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -376,55 +376,63 @@ goto cpplint
376376
if not defined cpplint goto jslint
377377
echo running cpplint
378378
set cppfilelist=
379-
setlocal enabledelayedexpansion
380-
for /f "tokens=*" %%G in ('dir /b /s /a src\*.c src\*.cc src\*.h ^
381-
test\addons\*.cc test\addons\*.h test\cctest\*.cc test\cctest\*.h ^
382-
test\gc\binding.cc tools\icu\*.cc tools\icu\*.h') do (
383-
set relpath=%%G
384-
set relpath=!relpath:*%~dp0=!
385-
call :add-to-list !relpath!
386-
)
387-
( endlocal
388-
set cppfilelist=%localcppfilelist%
389-
)
379+
set cpp_locs=src\*.c
380+
set cpp_locs=%cpp_locs% src\*.cc
381+
set cpp_locs=%cpp_locs% src\*.h
382+
set cpp_locs=%cpp_locs% test\addons\*.cc
383+
set cpp_locs=%cpp_locs% test\addons\*.h
384+
set cpp_locs=%cpp_locs% test\cctest\*.cc
385+
set cpp_locs=%cpp_locs% test\cctest\*.h
386+
set cpp_locs=%cpp_locs% test\gc\binding.cc
387+
set cpp_locs=%cpp_locs% tools\icu\*.cc
388+
set cpp_locs=%cpp_locs% tools\icu\*.h
389+
for /f "tokens=*" %%G in ('dir /b /s /a:, %cpp_locs%') do call :add-to-list %%G
390390
python tools/cpplint.py %cppfilelist%
391391
python tools/check-imports.py
392392
goto jslint
393393

394394
:add-to-list
395-
echo %1 | findstr /c:"src\node_root_certs.h"
396-
if %errorlevel% equ 0 goto exit
397-
398-
echo %1 | findstr /c:"src\queue.h"
399-
if %errorlevel% equ 0 goto exit
400-
401-
echo %1 | findstr /c:"src\tree.h"
402-
if %errorlevel% equ 0 goto exit
403-
404-
@rem skip subfolders under /src
405-
echo %1 | findstr /r /c:"src\\.*\\.*"
406-
if %errorlevel% equ 0 goto exit
407-
408-
echo %1 | findstr /r /c:"test\\addons\\[0-9].*_.*\.h"
409-
if %errorlevel% equ 0 goto exit
410-
411-
echo %1 | findstr /r /c:"test\\addons\\[0-9].*_.*\.cc"
412-
if %errorlevel% equ 0 goto exit
413-
414-
set "localcppfilelist=%localcppfilelist% %1"
395+
setlocal enabledelayedexpansion
396+
set base_path=
397+
set relpath=%1
398+
set relpath=!relpath:%~dp0=!
399+
endlocal&set relpath=%relpath%
400+
@rem findstr can do multiple searches, but only for regexes
401+
set find_arg=/r
402+
set find_arg=%find_arg% /c:"src\\node_root_certs\.h"
403+
set find_arg=%find_arg% /c:"src\\queue\.h"
404+
set find_arg=%find_arg% /c:"src\\tree\.h"
405+
set find_arg=%find_arg% /c:"src\\.*\\.*"
406+
set find_arg=%find_arg% /c:"test\\addons\\[0-9].*_.*\.h"
407+
set find_arg=%find_arg% /c:"test\\addons\\[0-9].*_.*\.cc"
408+
echo %relpath% | findstr %find_arg% > nul
409+
if not errorlevel 1 exit /b
410+
set "cppfilelist=%cppfilelist% %relpath%"
411+
exit /b
412+
413+
:find_node
414+
if exist %config%\node set nodeexe=%config%\node&exit /b
415+
where node > nul 2> nul
416+
if not errorlevel 1 set nodeexe=node&exit /b
417+
echo Could not file node.exe
415418
goto exit
419+
exit /b
416420

417421
:jslint
418422
if defined jslint_ci goto jslint-ci
419423
if not defined jslint goto exit
420424
if not exist tools\eslint\lib\eslint.js goto no-lint
425+
call :find_node
421426
echo running jslint
422-
%config%\node tools\eslint\bin\eslint.js --cache --rule "linebreak-style: 0" --rulesdir=tools\eslint-rules benchmark lib test tools
427+
%nodeexe% tools\eslint\bin\eslint.js --cache --rule "linebreak-style: 0" --rulesdir=tools\eslint-rules benchmark lib test tools
428+
if not errorlevel 1 echo jslint finished with no errors
423429
goto exit
424430

425431
:jslint-ci
432+
call :find_node
426433
echo running jslint-ci
427-
%config%\node tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib test tools
434+
%nodeexe% tools\jslint.js -J -f tap -o test-eslint.tap benchmark lib test tools
435+
if not errorlevel 1 echo jslint-ci finished with no errors
428436
goto exit
429437

430438
:no-lint
@@ -437,7 +445,7 @@ echo Failed to create vc project files.
437445
goto exit
438446

439447
:help
440-
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-inspector/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [sign] [x86/x64] [vc2015] [download-all] [enable-vtune] [lint/lint-ci]
448+
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-inspector/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/without-intl] [nobuild] [sign] [x86/x64] [vc2015] [download-all] [enable-vtune] [lint/lint-ci/jslint/jslint-ci]
441449
echo Examples:
442450
echo vcbuild.bat : builds release build
443451
echo vcbuild.bat debug : builds debug build

0 commit comments

Comments
 (0)