From c4b029f78d52c69ab2155d94de01f713f0e52fe2 Mon Sep 17 00:00:00 2001 From: tomamplius Date: Sun, 9 Oct 2022 09:35:21 +0200 Subject: [PATCH 1/3] remove move on / --- scripts/cleanup.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 94a3d7e2be..adfc3408dc 100644 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -1,16 +1,4 @@ #!/bin/bash -dir=$(pwd) -declare -a keep=("dist" "package.json" "yarn.lock" "client" "builder" "build" "pm2.config.js" "docker_run.sh") -for moveDir in "${keep[@]}" -do - mv $moveDir / 2>/dev/null -done -cd / -rm -r $dir -mkdir $dir -for keepDir in "${keep[@]}" -do - mv /$keepDir $dir/ 2>/dev/null -done -cd $dir +KEEP="dist package.json yarn.lock client builder build pm2.config.js docker_run.sh" +ls | grep -v $(echo ${KEEP} | awk '{split($0,a," ");for (i in a) printf "-e ^"a[i]"$ "}') | xargs rm -fr NODE_ENV=production yarn From bc8331ddd49f2e3ebf152ef442dc585089718fef Mon Sep 17 00:00:00 2001 From: tomamplius Date: Fri, 21 Oct 2022 21:09:03 +0200 Subject: [PATCH 2/3] use egrep to replace grep + awk --- scripts/cleanup.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index adfc3408dc..e13d7ff81c 100644 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -1,4 +1,5 @@ #!/bin/bash -KEEP="dist package.json yarn.lock client builder build pm2.config.js docker_run.sh" -ls | grep -v $(echo ${KEEP} | awk '{split($0,a," ");for (i in a) printf "-e ^"a[i]"$ "}') | xargs rm -fr +KEEP="dist|package.json|yarn.lock|client|builder|build|pm2.config.js|docker_run.sh" +echo "Removing unneeded build files:" +ls | egrep -v $KEEP | xargs rm -rf NODE_ENV=production yarn From 75559dddce00a92e8236354edc01c635ec524a98 Mon Sep 17 00:00:00 2001 From: tomamplius Date: Fri, 21 Oct 2022 21:09:54 +0200 Subject: [PATCH 3/3] add verbose to rm --- scripts/cleanup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index e13d7ff81c..aa4286c7e7 100644 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -1,5 +1,5 @@ #!/bin/bash KEEP="dist|package.json|yarn.lock|client|builder|build|pm2.config.js|docker_run.sh" echo "Removing unneeded build files:" -ls | egrep -v $KEEP | xargs rm -rf +ls | egrep -v $KEEP | xargs rm -rfv NODE_ENV=production yarn