Skip to content

Commit 455c89c

Browse files
authored
fix: support running script with versioned package manager (#40)
Passing package manager with version or tag will not produce error since value is processed before usage.
1 parent 1063c79 commit 455c89c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.circleci/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
steps:
122122
- checkout
123123
- core/run_script:
124-
pkg_manager: pnpm
124+
pkg_manager: pnpm@latest-10
125125
pkg_json_dir: ~/project/sample
126126
script: test --json --outputFile=results_pnpm.json
127127
- run:

src/scripts/run-script.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
echo "Running custom script from package.json at ${PWD}"
44

5+
PKG_MANAGER=$(circleci env subst "${PARAM_STR_PKG_MANAGER}")
6+
PKG_MANAGER_REGEX="^(npm|pnpm)(@.+)?$"
7+
8+
if [[ "${PKG_MANAGER}" =~ ${PKG_MANAGER_REGEX} ]]; then
9+
PKG_MANAGER="${BASH_REMATCH[1]}"
10+
else
11+
echo "Cannot run script with unsupported package manager '${PKG_MANAGER}'"
12+
13+
exit 1
14+
fi
15+
516
set -x
6-
eval "${PARAM_STR_PKG_MANAGER}" run "${PARAM_STR_SCRIPT}"
17+
eval "${PKG_MANAGER}" run "${PARAM_STR_SCRIPT}"
718
set +x

0 commit comments

Comments
 (0)