Commit 3fb863d1 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgs: preserve parent directory when KEEP_DIRS contains subdir paths

When KEEP_DIRS contains 'web/node_modules', the cleanup was deleting the 'web' parent directory because grep only matched '^web/node_modules$' not '^web$'. Now also add parent dir to grep pattern.
parent 2c31fc23
......@@ -860,7 +860,7 @@ update_predownloaded()
[ "$MODE" = "production" ] && PRODUCTION='--omit=dev'
info "Detected npm install hook in $npm_dir, running ..."
info "Detected npm install hook in $npm_dir (RGD=$RGD, CURNAME=$CURNAME), running ..."
pushd "$npm_dir" >/dev/null
docmd npm install $VERBOSE --omit=optional --ignore-scripts $PRODUCTION || fatal
popd >/dev/null
......@@ -910,7 +910,11 @@ update_predownloaded()
info "Cleaning up, keeping:$KEEP_DIRS ..."
local grep_args=""
for i in $KEEP_DIRS ; do
# Match exact dir name; for subdir paths (web/node_modules) also keep parent dir
grep_args="$grep_args -e ^${i}$"
case "$i" in
*/*) grep_args="$grep_args -e ^${i%%/*}$" ;;
esac
done
rm -rf $(ls -1 | grep -v $grep_args) .[a-zA-Z0-9]*
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment