@@ -39,6 +39,28 @@ copyConfig() {
39
39
cp -f $TOOLS_ROOT /config/cypress.config.dist.mjs $WORKDIR /tests/cypress.config.mjs
40
40
}
41
41
42
+ # Install dependencies
43
+ installDependencies () {
44
+ cd $WORKDIR /tests/
45
+
46
+ if [ ${PACKAGE_MANAGER_PREFS:- npm} == ' pnpm' ]; then
47
+ if [ ! -f $WORKDIR /tests/pnpm-lock.yaml ] && [ -f $WORKDIR /tests/package-lock.json ]; then
48
+ pnpm import package-lock.json
49
+ fi
50
+ if [ ! -f $WORKDIR /tests/pnpm-lock.yaml ]; then
51
+ pnpm install
52
+ else
53
+ pnpm install --frozen-lockfile
54
+ fi
55
+ else
56
+ if [ ! -f $WORKDIR /tests/package-lock.json ]; then
57
+ npm i
58
+ else
59
+ npm ci
60
+ fi
61
+ fi
62
+ }
63
+
42
64
# Setup configuration file
43
65
# Backup the original file if a backup file not already exists and .env variable is not set to false/no/0
44
66
# Copy the configuration file to the working directory if .env variable is set to true/yes
@@ -162,36 +184,45 @@ if [ ! -f $WORKDIR/tests/package.json ]; then
162
184
echo " [ATTENTION] No package.json found in the tests folder. A general default one will be injected."
163
185
cp -f $TOOLS_ROOT /config/package.json $WORKDIR /tests/package.json
164
186
cp -f $TOOLS_ROOT /config/package-lock.json $WORKDIR /tests/package-lock.json
187
+ cp -f $TOOLS_ROOT /config/pnpm-lock.yaml $WORKDIR /tests/pnpm-lock.yaml
165
188
fi
166
189
167
190
# Set the correct permissions
168
- chown node:node $WORKDIR /tests/package.json $WORKDIR /tests/package-lock.json
191
+ chown node:node $WORKDIR /tests/package.json
192
+
193
+ if [ -f $WORKDIR /tests/pnpm-lock.yaml ]; then
194
+ chown node:node $WORKDIR /tests/pnpm-lock.yaml
195
+ fi
196
+
197
+ if [ -f $WORKDIR /tests/package-lock.json ]; then
198
+ chown node:node $WORKDIR /tests/package-lock.json
199
+ fi
169
200
170
201
# Install the assets
171
202
if [ -f $WORKDIR /tests/package.json ]; then
172
203
case ${NPM_DEPS_INSTALL:- smart} in
173
204
always)
174
205
echo " Cleaning the assets"
175
206
rm -rf $WORKDIR /tests/node_modules
207
+ if [ ${PACKAGE_MANAGER_PREFS:- npm} == ' pnpm' ]; then
208
+ cd $WORKDIR /tests && pnpm store prune
209
+ fi
176
210
echo -e " > Installing the assets (takes a while!)"
177
- cd $WORKDIR /tests/
178
- npm ci
211
+ installDependencies
179
212
;;
180
213
* )
181
214
if [ ! -d $WORKDIR /tests/node_modules ]; then
182
215
echo -e " > Installing the assets (takes a while!)"
183
- cd $WORKDIR /tests/
184
- npm ci
216
+ installDependencies
185
217
elif [ -d $WORKDIR /tests/node_modules ] && [[ $( find " $WORKDIR /tests/node_modules" -type d -mtime +1 -print) ]]; then
186
218
echo " Assets already installed but older than 1 day"
187
219
echo " Cleaning the assets"
188
220
rm -rf $WORKDIR /tests/node_modules
189
221
echo -e " > Installing the assets (takes a while!)"
190
- cd $WORKDIR /tests/
191
- npm ci
222
+ installDependencies
192
223
else
193
224
echo " Assets already installed"
194
- echo " Skipping npm install"
225
+ echo " Skipping ${PACKAGE_MANAGER_PREFS :- npm} install"
195
226
fi
196
227
;;
197
228
esac
0 commit comments