From 5c0238ac99a84d6b4d30767124cd6532ecfbe9bb Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Tue, 18 Oct 2022 11:04:44 +0800 Subject: [PATCH] u --- git-pull-all.bat | 10 ++++---- git-pull-recursive.sh | 2 +- npm-boot-all.sh | 2 +- npm-boot-recursive.bat | 54 +++++++++++++++++++++++++++++++++++++++++ npm-boot-recursive.sh | 47 +++++++++++++++++++++++++++++++++++ npm-clear-all.bat | 24 +++++++++--------- npm-clear-recursive.bat | 2 +- 7 files changed, 122 insertions(+), 19 deletions(-) create mode 100644 npm-boot-recursive.bat create mode 100644 npm-boot-recursive.sh diff --git a/git-pull-all.bat b/git-pull-all.bat index d7ee059..23841ec 100644 --- a/git-pull-all.bat +++ b/git-pull-all.bat @@ -37,10 +37,10 @@ for /d %%o in (*) do ( @REM windows的链接文件会造成路径错误,从而终止该循环,从而导致下一轮乃至所有循环的工作目录错误。因此要过滤掉 .vscode 这个符号链接目录。 if not "%%o" == ".vscode" ( @REM 如果同时使用了 GIT 和 云盘进行管理,每次 git pull 都会造成 .git 目录下某些文件变化,导致云盘不断自动同步。因此过滤掉云盘的目录不做更新。 - echo %%o | findstr "=" >NUL && ( - echo !!!!!!!! omitting [%FONPATH%\%%o] !!!!!!!! - echo; - ) || ( + @REM echo %%o | findstr "=" >NUL && ( + @REM echo !!!!!!!! omitting [%FONPATH%\%%o] !!!!!!!! + @REM echo; + @REM ) || ( echo ======== entering [%FONPATH%\%%o] ======== echo; pushd %%o @@ -54,7 +54,7 @@ for /d %%o in (*) do ( ) ) popd - ) + @REM ) ) ) diff --git a/git-pull-recursive.sh b/git-pull-recursive.sh index b5d8567..ff6125c 100644 --- a/git-pull-recursive.sh +++ b/git-pull-recursive.sh @@ -32,7 +32,7 @@ pushd $FONPATH echo "*** Starting from [`pwd`] ***" echo "" -find . -mindepth 1 -maxdepth 3 -type d -name '?*.git' | grep -v 'node_modules' | while read repo +find . -mindepth 1 -maxdepth 3 -type d -name '?*' | grep -v 'node_modules' | while read repo do if [ -d "$repo/.git" ] then diff --git a/npm-boot-all.sh b/npm-boot-all.sh index 1aba95c..0236dce 100755 --- a/npm-boot-all.sh +++ b/npm-boot-all.sh @@ -42,7 +42,7 @@ do echo "<<<< npm booting: [$org/$repo] <<<<" cd "$repo" npm run boot - echo ">>>> npm bootted: [$org/$repo] >>>>" + echo ">>>> npm booted: [$org/$repo] >>>>" echo "" cd .. fi diff --git a/npm-boot-recursive.bat b/npm-boot-recursive.bat new file mode 100644 index 0000000..bdbe441 --- /dev/null +++ b/npm-boot-recursive.bat @@ -0,0 +1,54 @@ +@echo off + +@REM 首先清除可能残留的变量 +set FONPATH= + +@ if not "" == "%1" ( + set FONPATH=%1 +) else ( + if exist D:\faronear ( + set FONPATH=D:\faronear + ) else (if exist C:\faronear ( + set FONPATH=C:\faronear + ) else (if exist %HOMEDRIVE%%HOMEPATH%\faronear ( + set FONPATH=%HOMEDRIVE%%HOMEPATH%\faronear + ) else ( + echo === Enter [target path] or leave [blank] for default to `.` + set /p FONPATH=">>> " + echo; + if "" == "%FONPATH%" ( + set FONPATH=. + ) + ))) +) + +if not exist "%FONPATH%" ( + echo *** [%FONPATH%] not exist! Exit now. *** + @ GOTO END +) + +pushd %FONPATH% +echo *** Starting from [%CD%] *** +echo; + +for /d /r %%r in (*) do ( + @REM windows的链接文件会造成路径错误,从而终止该循环,从而导致下一轮乃至所有循环的工作目录错误。因此要过滤掉 .vscode 这个符号链接目录。 + if not "%%r" == ".vscode" ( + if exist "%%r\package.json" ( + findstr "\"boot\"" "%%r\package.json" >NUL && ( + pushd %%r + echo ---- npm booting [%FONPATH%\%%r] ---- + npm run boot + echo; + popd + ) + ) + ) +) + +popd + +:END + +pause + diff --git a/npm-boot-recursive.sh b/npm-boot-recursive.sh new file mode 100644 index 0000000..b21d613 --- /dev/null +++ b/npm-boot-recursive.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +if [ $1 ] +then + FONPATH=$1 +elif [ -d /faronear ] +then + FONPATH=/faronear +elif [ -d ~/faronear ] +then + FONPATH=~/faronear +elif [ -d /mnt/d/faronear ] +then + FONPATH=/mnt/d/faronear +else + echo "=== Enter [target path] or leave [blank] for default to `.`" + read -p ">>> " FONPATH + echo "" + if [ ! $FONPATH ] + then + FONPATH=. + fi +fi + +if [ ! -d $FONPATH ] +then + echo "*** [$FONPATH] not exist! Exit now. ***" + exit +fi + +pushd $FONPATH +echo "*** Starting from [`pwd`] ***" +echo "" + +find . -mindepth 1 -maxdepth 3 -type d -name '?*' | grep -v 'node_modules' | while read repo +do + if ( [ -f "$repo/package.json" ] && grep -q '"boot"' "$repo/package.json" ) + then + echo "---- npm booting: [`pwd`/$repo] ----" + pushd "$repo" + npm run boot + echo "---- npm booted: [`pwd`/$repo] ----" + echo "" + popd + fi +done +popd diff --git a/npm-clear-all.bat b/npm-clear-all.bat index ac9d8c2..fed24e5 100644 --- a/npm-clear-all.bat +++ b/npm-clear-all.bat @@ -34,19 +34,21 @@ echo; @REM for /d %%d in (*) do ( pushd %%d & ( for /d %%d in (*) do ( if exist %%d/.git pushd %%d & echo --- git pulling: %%d ... & git pull & popd ) ) & popd ) for /d %%o in (*) do ( - echo ======== entering [%FONPATH%\%%o] ======== - echo; - pushd %%o - for /d %%g in (*) do ( - if exist %%g\node_modules ( - pushd %%g - echo ---- Deleting [%%g\node_modules] ---- - rd /s /q node_modules - echo; - popd + @ if not "%%o" == ".vscode" ( + echo ======== entering [%FONPATH%\%%o] ======== + echo; + pushd %%o + for /d %%g in (*) do ( + if exist %%g\node_modules ( + pushd %%g + echo ---- Deleting [%%g\node_modules] ---- + rd /s /q node_modules + echo; + popd + ) ) + popd ) - popd ) popd diff --git a/npm-clear-recursive.bat b/npm-clear-recursive.bat index c611bcd..6b80fd0 100644 --- a/npm-clear-recursive.bat +++ b/npm-clear-recursive.bat @@ -34,7 +34,7 @@ echo; for /d /r %%r in (*) do ( @REM windows的链接文件会造成路径错误,从而终止该循环,从而导致下一轮乃至所有循环的工作目录错误。因此要过滤掉 .vscode 这个符号链接目录。 if not "%%r" == ".vscode" ( - if exist "%%r\.git" ( + if exist "%%r\node_modules" ( pushd "%%r" echo ---- Deleting [%FONPATH%\%%r] ---- rd /s /q node_modules