From d8c7f0095e792d0d66a5d7f49d7c00219dfa2b54 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Fri, 9 Jul 2021 17:10:33 +0800 Subject: [PATCH] u --- git-pull-all.bat | 26 +++++++++++++++++++------- git-pull-all.sh | 37 +++++++++++++++++++++---------------- npm-boot-all.bat | 14 +++++++------- npm-boot-all.sh | 36 ++++++++++++++++++++---------------- press-anykey-to-exit.sh | 15 +++++++++++++++ 5 files changed, 82 insertions(+), 46 deletions(-) create mode 100644 press-anykey-to-exit.sh diff --git a/git-pull-all.bat b/git-pull-all.bat index e841ba4..77941f8 100644 --- a/git-pull-all.bat +++ b/git-pull-all.bat @@ -1,17 +1,29 @@ @echo off @ IF "%1" == "" (if exist D:\faronear (set BASEDIR=D:\faronear) else (set BASEDIR=..\..)) else (set BASEDIR=%1) -echo [ Goto %BASEDIR% as base directory ] + +if not exist %BASEDIR% ( + echo *** [%BASEDIR%] not exist! Exit now. *** + @ GOTO END +) pushd %BASEDIR% -echo [ %CD% ] -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 +echo *** Current path = [%CD%] *** +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 +) popd + pause @GOTO END -:EMPTY -@ echo Empty target! Please assign a target path. -@ GOTO END - :END diff --git a/git-pull-all.sh b/git-pull-all.sh index 8ca6d3b..9a3b06a 100755 --- a/git-pull-all.sh +++ b/git-pull-all.sh @@ -4,32 +4,37 @@ if [ $1 ] then FONPATH=$1 else - read -p "Enter path to git pull (leave blank for default ../..) >> " FONPATH + read -p "Enter faronear path to git pull (leave blank for default ../..) >> " FONPATH if [ ! $FONPATH ] then FONPATH=../.. fi fi -echo ">> Goto $FONPATH as base directory" + +if [ ! -d $FONPATH ] +then + echo "*** [$FONPATH] not exist! Exit now. ***" + exit +fi pushd $FONPATH -echo ">> `pwd`" +echo "*** Current path = [`pwd`] ***" for org in `ls .` do if [ -d $org ] - then - cd $org; - for repo in `ls .` - do - if [ -d $repo/.git ] - then - echo '>>>>>> git pulling: ' $org/$repo - cd $repo - git pull - cd .. - fi - done - cd ..; + then + cd $org; + for repo in `ls .` + do + if [ -d $repo/.git ] + then + echo "--- git pulling: $org/$repo" + cd $repo + git pull + cd .. + fi + done + cd ..; fi done popd \ No newline at end of file diff --git a/npm-boot-all.bat b/npm-boot-all.bat index b80f862..ec24426 100644 --- a/npm-boot-all.bat +++ b/npm-boot-all.bat @@ -1,17 +1,17 @@ @echo off @ IF "%1" == "" (if exist D:\faronear (set BASEDIR=D:\faronear) else (set BASEDIR=..\..)) else (set BASEDIR=%1) -echo [ Goto %BASEDIR% as base directory ] + +if not exist %BASEDIR% ( + echo *** [%BASEDIR%] not exist! Exit now. *** + @ GOTO END +) pushd %BASEDIR% -echo [ %CD% ] +echo *** Current path = [%CD%] *** for /d %%d in (*) do pushd %%d & (for /d %%d in (*) do if exist %%d/package.json (pushd %%d & echo --- npm booting: %%d ... & npm run boot & popd)) & popd popd -pause -@GOTO END -:EMPTY -@ echo Empty target! Please assign a target path. -@ GOTO END +pause :END diff --git a/npm-boot-all.sh b/npm-boot-all.sh index 1fad0d1..904f346 100755 --- a/npm-boot-all.sh +++ b/npm-boot-all.sh @@ -4,33 +4,37 @@ if [ $1 ] then FONPATH=$1 else - read -p "Enter path to npm boot (leave blank for default ../..) >> " FONPATH + read -p "Enter faronear path to npm boot (leave blank for default ../..) >> " FONPATH if [ ! $FONPATH ] then FONPATH=../.. fi fi -echo ">> Goto $FONPATH as base directory" +if [ ! -d $FONPATH ] +then + echo "*** [$FONPATH] not exist! Exit now. ***" + exit +fi pushd $FONPATH -echo ">> Current path = `pwd`" +echo "*** Current path = [`pwd`] ***" for org in `ls .` do if [ -d $org ] - then - cd $org; - for repo in `ls .` - do - if [ -f $repo/package.json ] - then - echo '>>>>>> npm booting: ' $org/$repo - cd $repo - npm run boot - cd .. - fi - done - cd ..; + then + cd $org; + for repo in `ls .` + do + if [ -f $repo/package.json ] + then + echo '>>>>>> npm booting: ' $org/$repo + cd $repo + npm run boot + cd .. + fi + done + cd ..; fi done popd \ No newline at end of file diff --git a/press-anykey-to-exit.sh b/press-anykey-to-exit.sh new file mode 100644 index 0000000..1856a4b --- /dev/null +++ b/press-anykey-to-exit.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +get_char() +{ + SAVEDSTTY=`stty -g` + stty -echo + stty cbreak + dd if=/dev/tty bs=1 count=1 2> /dev/null + stty -raw + stty echo + stty $SAVEDSTTY +} + +echo "Press any key to exit!" +char=`get_char`