Skip to content

Instantly share code, notes, and snippets.

@dpilafian
Last active May 29, 2023 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpilafian/3f0ef3a4a5b089573b85c046139a438e to your computer and use it in GitHub Desktop.
Save dpilafian/3f0ef3a4a5b089573b85c046139a438e to your computer and use it in GitHub Desktop.
Loop through all projects and pull latest files and run test suites
@echo off
::::::::::::::::::
:: npm Test All ::
::::::::::::::::::
:: For those who don't develop on Windows but must still test on Windows...
:: Flags:
:: --nuke
:: Deletes each "node_modules" folders for fresh installs
:: --test
:: Skips npm install and jumps straight to running the tests
::
:: Setup:
:: Download and install node from https://nodejs.org (during install
:: check "Automaticaly install the necessary tools" for Chocolate).
:: Download and install GitHub Desktop from https://desktop.github.com (and
:: clone repositories into a "projects" folder)
set projectsFolder=%UserProfile%\projects
set start=%time%
::::::::::::::::::::::::::::::::
echo.
echo npm Test All
echo ============
cd %projectsFolder%
if not exist %projectsFolder% echo Invalid folder: %projectsFolder% && exit /b
echo %* | find "--nuke" && set nukeMode=on || set nukeMode=
echo %* | find "--test" && set testMode=on || set testMode=
if defined nukeMode echo NOTE: Deleting node_modules folders for fresh installs
if defined testMode echo NOTE: Using fast "test only" mode to skip installs
cd
ver
echo node
node --version
echo.
::::::::::::::::::::::::::::::::
cd %projectsFolder%
for /d %%i in ("*") do if exist %%i\package.json (
echo ------------------------------------------
echo %%i
cd %%i
cd
echo git...
git ls-files dist/ | find "/" && git restore dist/
git ls-files docs/ | find "/" && git restore docs/
git ls-files spec/fixtures/target/ | find "/" && git restore spec/fixtures/target/
git pull --ff-only
if not defined testMode echo npm...
if defined nukeMode echo Deleting node_modules && rmdir /s /q node_modules
if not defined testMode call npm install --no-fund
if not defined testMode call npm update --no-fund
cd %projectsFolder%
echo.
)
echo *** Setup complete ***
echo.
::::::::::::::::::::::::::::::::
cd %projectsFolder%
for /d %%i in ("*") do if exist %%i\package.json (
echo ------------------------------------------
echo %%i
cd %%i
cd
call npm test
cd %projectsFolder%
echo.
)
echo *** Testing complete ***
echo.
::::::::::::::::::::::::::::::::
cd %projectsFolder%
echo Start: %start%
echo End: %time%
echo Done.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment