From e1c55a2da72e2d3a0a059cc4f8affac0f48dc836 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 012a007116f3fc3c524a54b212c930d3dd33ff8b 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 1f29047958e8f69a06103a2a5b4e239b6dc19b0c 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