Check if file exists before patching

This commit is contained in:
q 2024-09-14 19:05:29 -04:00
parent c375363a8c
commit 1595d59bda

View File

@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with element-web-patches. If not, see <https://www.gnu.org/licenses/>.
set -euo pipefail
LWD="$PWD"
echo "Removing links to nonfree services..."
error() {
@ -22,7 +25,11 @@ error() {
exit 1
}
patch_content=$(cat << EOF
cd "${1}"
if test -f "./node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js"; then
patchjs_content=$(cat << EOF
--- a/node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js
+++ b/node_modules/matrix-react-sdk/lib/components/views/dialogs/ShareDialog.js
@@ -37,28 +37,6 @@
@ -54,6 +61,15 @@ patch_content=$(cat << EOF
name: "email",
img: require("../../../../res/img/social/email-1.png"),
url: url => \`mailto:?body=\${url}\`
EOF
)
echo "${patchjs_content}" | patch -t -p1 || error
fi
if test -f "./node_modules/matrix-react-sdk/src/components/views/dialogs/ShareDialog.tsx"; then
patchtsx_content=$(cat << EOF
--- a/node_modules/matrix-react-sdk/src/components/views/dialogs/ShareDialog.tsx
+++ b/node_modules/matrix-react-sdk/src/components/views/dialogs/ShareDialog.tsx
@@ -31,30 +31,6 @@
@ -90,8 +106,6 @@ patch_content=$(cat << EOF
EOF
)
(cd "${1}" && echo "${patch_content}" | patch -p1) || error
rm -f "${1}"/node_modules/matrix-react-sdk/res/img/social/facebook.png \
"${1}"/node_modules/matrix-react-sdk/res/img/social/linkedin.png \
"${1}"/node_modules/matrix-react-sdk/res/img/social/reddit.png \
"${1}"/node_modules/matrix-react-sdk/res/img/social/twitter-2.png \
echo "${patchtsx_content}" | patch -t -p1 || error
fi
cd $LWD