File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
5559fi
Original file line number Diff line number Diff 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
5054fi
You can’t perform that action at this time.
0 commit comments