From 588d4f3689e5fb95bc4101dc559664af4788e4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roni=20V=C3=A4yrynen?= Date: Tue, 16 May 2023 13:10:01 +0300 Subject: [PATCH] feat: add automatic yarn cache cleanup with a config option --- sample.xo-install.cfg | 5 +++++ xo-install.sh | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/sample.xo-install.cfg b/sample.xo-install.cfg index 73dc00a..3f06ee9 100644 --- a/sample.xo-install.cfg +++ b/sample.xo-install.cfg @@ -58,6 +58,11 @@ PLUGINS="all" # options: true/false AUTOUPDATE="true" +# yarn cache can consume a lot of disk space over time. Setting this to true will clear cache after update. +# this can have a negative impact on how long update will take with slower internet connections +# options: true/false +#YARN_CACHE_CLEANUP="false" + # enable/disable OS check. Installation refuses to run on any other than supported OS versions if this is enabled. Can be disabled for experimental purposes. # options: true/false OS_CHECK="true" diff --git a/xo-install.sh b/xo-install.sh index 07f7876..13733f1 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -48,6 +48,7 @@ USESUDO="${USESUDO:-"false"}" GENSUDO="${GENSUDO:-"false"}" INSTALL_REPOS="${INSTALL_REPOS:-"true"}" SYSLOG_TARGET="${SYSLOG_TARGET:-""}" +YARN_CACHE_CLEANUP="${YARN_CACHE_CLEANUP:-"false"}" # set variables not changeable in configfile TIME=$(date +%Y%m%d%H%M) @@ -949,6 +950,14 @@ function UpdateXO { done printok "Removing old inactive installations after update. Leaving $PRESERVE latest" echo + + # clear yarn cache if defined in configuration + if [[ "$YARN_CACHE_CLEANUP" == "true" ]]; then + printprog "Cleaning yarn cache" + runcmd "yarn cache clean" + printok "Cleaning yarn cache" + echo + fi } function InstallXOProxy {