Skip to content

Commit cef2898

Browse files
committed
Fix
1 parent 50f61db commit cef2898

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

packages/core/scripts/sentry-xcode-debug-files.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ if [ -z "$SENTRY_CLI_EXECUTABLE" ]; then
4444

4545
if [ -f "$PNPM_BIN_PATH" ]; then
4646
NODE_PATH_VALUE=$(grep -oE 'NODE_PATH="[^"]+"' "$PNPM_BIN_PATH" | head -n1 | sed -E 's/^NODE_PATH="([^"]*)"/\1/')
47-
# Strip everything from the first `@sentry/cli/` onwards. If `%%` finds no match
48-
# PREFIX equals NODE_PATH_VALUE and we leave SENTRY_CLI_PACKAGE_PATH unset.
49-
SENTRY_CLI_PREFIX="${NODE_PATH_VALUE%%@sentry/cli/*}"
50-
if [ -n "$NODE_PATH_VALUE" ] && [ "$SENTRY_CLI_PREFIX" != "$NODE_PATH_VALUE" ]; then
51-
SENTRY_CLI_PACKAGE_PATH="${SENTRY_CLI_PREFIX}@sentry/cli/bin/sentry-cli"
52-
fi
47+
# Split on ':' and pick the first entry containing `@sentry/cli/`. Handling each
48+
# entry separately avoids producing colon-joined garbage when the matching entry
49+
# isn't the first one in NODE_PATH.
50+
IFS=':' read -ra NODE_PATH_ENTRIES <<< "$NODE_PATH_VALUE"
51+
for entry in "${NODE_PATH_ENTRIES[@]}"; do
52+
if [[ "$entry" == *@sentry/cli/* ]]; then
53+
SENTRY_CLI_PACKAGE_PATH="${entry%%@sentry/cli/*}@sentry/cli/bin/sentry-cli"
54+
break
55+
fi
56+
done
5357
fi
5458
fi
5559
fi

packages/core/scripts/sentry-xcode.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ if [ -z "$SENTRY_CLI_EXECUTABLE" ]; then
3939

4040
if [ -f "$PNPM_BIN_PATH" ]; then
4141
NODE_PATH_VALUE=$(grep -oE 'NODE_PATH="[^"]+"' "$PNPM_BIN_PATH" | head -n1 | sed -E 's/^NODE_PATH="([^"]*)"/\1/')
42-
# Strip everything from the first `@sentry/cli/` onwards. If `%%` finds no match
43-
# PREFIX equals NODE_PATH_VALUE and we leave SENTRY_CLI_PACKAGE_PATH unset.
44-
SENTRY_CLI_PREFIX="${NODE_PATH_VALUE%%@sentry/cli/*}"
45-
if [ -n "$NODE_PATH_VALUE" ] && [ "$SENTRY_CLI_PREFIX" != "$NODE_PATH_VALUE" ]; then
46-
SENTRY_CLI_PACKAGE_PATH="${SENTRY_CLI_PREFIX}@sentry/cli/bin/sentry-cli"
47-
fi
42+
# Split on ':' and pick the first entry containing `@sentry/cli/`. Handling each
43+
# entry separately avoids producing colon-joined garbage when the matching entry
44+
# isn't the first one in NODE_PATH.
45+
IFS=':' read -ra NODE_PATH_ENTRIES <<< "$NODE_PATH_VALUE"
46+
for entry in "${NODE_PATH_ENTRIES[@]}"; do
47+
if [[ "$entry" == *@sentry/cli/* ]]; then
48+
SENTRY_CLI_PACKAGE_PATH="${entry%%@sentry/cli/*}@sentry/cli/bin/sentry-cli"
49+
break
50+
fi
51+
done
4852
fi
4953
fi
5054
fi

0 commit comments

Comments
 (0)