From 1990880a1314df0c70b1e10bd90873bd955bc76b Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Mon, 23 Aug 2021 12:39:32 -0600 Subject: [PATCH] fix(install): When PVW is used as dependency --- config/prebuild.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/config/prebuild.sh b/config/prebuild.sh index 976b7fd23..fa9d24894 100755 --- a/config/prebuild.sh +++ b/config/prebuild.sh @@ -1,3 +1,76 @@ #!/bin/bash # FROM: https://github.com/JetBrains/svg-sprite-loader/issues/359#issuecomment-738834513 -cat ./config/funcMock.js > ./node_modules/svg-sprite-loader/lib/utils/get-matched-rule.js \ No newline at end of file + +function abspath() { + # generate absolute path from relative path + # $1 : relative filename + # return : absolute path + if [ -d "$1" ]; then + # dir + (cd "$1"; pwd) + elif [ -f "$1" ]; then + # file + if [[ $1 = /* ]]; then + echo "$1" + elif [[ $1 == */* ]]; then + echo "$(cd "${1%/*}"; pwd)/${1##*/}" + else + echo "$(pwd)/$1" + fi + fi +} + +CURRENT_DIR=`abspath .` +SRC_FILE=`abspath ./config/funcMock.js` +DST_FILE="./node_modules/svg-sprite-loader/lib/utils/get-matched-rule.js" + +cd $CURRENT_DIR +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi +cd .. +if [ -f "$DST_FILE" ]; then + cat "$SRC_FILE" > "$DST_FILE" + exit 0 +fi