Skip to content

Commit 90f86bb

Browse files
authored
fix: update $PATH to use $PNPM_HOME/bin, make $PNPM_DIRECTORY relative to $DDEV_APPROOT (#13)
1 parent e437180 commit 90f86bb

6 files changed

Lines changed: 28 additions & 9 deletions

File tree

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{bats,sh,yml,yaml}]
15+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
tests/ export-ignore
33
.github/ export-ignore
44
.gitattributes export-ignore
5+
.editorconfig export-ignore

commands/web/pnpm

100644100755
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ fi
1414

1515
# If a $PNPM_DIRECTORY is set, run our PNPM commands in that directory
1616
if [ -n "$PNPM_DIRECTORY" ]; then
17-
pnpm --dir "$PNPM_DIRECTORY" "$@"
18-
else
19-
pnpm "$@"
17+
mkdir -p "$DDEV_APPROOT/$PNPM_DIRECTORY"
18+
cd "$DDEV_APPROOT/$PNPM_DIRECTORY" || {
19+
echo "Error: Failed to change directory to '$DDEV_APPROOT/$PNPM_DIRECTORY'." >&2
20+
exit 1
21+
}
2022
fi
23+
24+
pnpm "$@"

tests/test.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ health_checks() {
5858
assert_file_exist package.json
5959
fi
6060

61-
run ddev pnpm link
61+
run ddev pnpm link .
6262
assert_success
6363
}
6464

@@ -126,7 +126,7 @@ teardown() {
126126
# Verify is-odd@3.0.1 is stored in the global cache after installing
127127
run ddev pnpm install
128128
assert_success
129-
run ddev exec bash -c "grep -r 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '3.0.1'"
129+
run ddev exec bash -c "grep -R 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '3.0.1'"
130130
assert_success
131131

132132
# Install the same package version from a second directory and verify it is reused from cache
@@ -141,7 +141,7 @@ teardown() {
141141
run ddev exec bash -c "cd /var/www/html/third && pnpm install"
142142
assert_success
143143

144-
run ddev exec bash -c "grep -r 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '2.0.0'"
144+
run ddev exec bash -c "grep -R 'is-odd' /mnt/ddev-global-cache/pnpm 2>/dev/null | grep '2.0.0'"
145145
assert_success
146146

147147
run ddev exec bash -c "node -e \"console.log(require('/var/www/html/third/node_modules/is-odd/package.json').version)\""

tests/testdata/frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"keywords": [],
1010
"author": "",
1111
"license": "ISC",
12-
"packageManager": "pnpm@10.5.2",
1312
"dependencies": {
1413
"is-odd": "3.0.1"
1514
}

web-build/Dockerfile.pnpm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ RUN (command -v pnpm >/dev/null 2>&1 || npm install --global pnpm) && \
44
PNPM_SCRIPT=$(printf '%s\n' \
55
'export PNPM_HOME="/mnt/ddev-global-cache/pnpm"' \
66
'case ":$PATH:" in' \
7-
' *":$PNPM_HOME:"*) ;;' \
8-
' *) PATH="$PNPM_HOME:$PATH" ;;' \
7+
' *":$PNPM_HOME/bin:"*) ;;' \
8+
' *) PATH="$PNPM_HOME/bin:$PATH" ;;' \
99
'esac' \
1010
'export PATH') && \
1111
echo "$PNPM_SCRIPT" >> /etc/bash.bashrc && \

0 commit comments

Comments
 (0)