Skip to content

Commit 8d34399

Browse files
build: improve update script error handling (#832)
Co-authored-by: Bill Glesias <[email protected]>
1 parent 493bf3f commit 8d34399

6 files changed

+63
-0
lines changed

docs/MAINTENANCE.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ Again, this needs to be repeated if you change the base node version using nvm.
4040

4141
- [Visual Studio Code](https://code.visualstudio.com/) or other editor
4242

43+
Under Microsoft Windows it may be necessary to also execute the following preparatory command:
44+
45+
```bash
46+
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe" --location user
47+
```
48+
4349
## Updating examples
4450

4551
When a new version of [Cypress](https://docs.cypress.io/guides/references/changelog) is published, the examples can be updated.

scripts/check-package-manager-npm.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# This script checks that the prerequisite
3+
# npm is installed
4+
5+
if ! command -v npm &> /dev/null
6+
then
7+
echo "**npm is required and not installed**"
8+
echo "install Node.js LTS from:"
9+
echo "https://nodejs.org/en/"
10+
echo "or install and use nvm"
11+
echo
12+
exit 1 # failure
13+
else
14+
echo "npm is installed"
15+
fi
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# This script checks that the prerequisites
3+
# pnpm and yarn are installed
4+
5+
pnpmInstalled=false
6+
if ! command -v pnpm &> /dev/null
7+
then
8+
echo "**pnpm not installed**"
9+
echo "execute the following command:"
10+
echo "npm install pnpm -g"
11+
echo
12+
else
13+
pnpmInstalled=true
14+
fi
15+
16+
yarnInstalled=false
17+
if ! command -v yarn &> /dev/null
18+
then
19+
echo "**yarn not installed**"
20+
echo "execute the following command:"
21+
echo "npm install yarn -g"
22+
echo
23+
else
24+
yarnInstalled=true
25+
fi
26+
27+
if $pnpmInstalled == true && $yarnInstalled == true
28+
then
29+
echo "pnpm and yarn are installed"
30+
else
31+
exit 1 # failure
32+
fi

scripts/update-cypress-latest-npm.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e # fail on error
23
#
34
# All examples using npm technology are updated to
45
# Cypress latest version

scripts/update-cypress-latest-other.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/bash
2+
set -e # fail on error
23
#
34
# Examples using yarn and pnpm package managers are
45
# updated to Cypress latest version
56
#
7+
# Make sure that pnpm and yarn are installed
8+
./scripts/check-package-managers-other.sh
69

710
echo updating yarn examples to Cypress latest version
811
cd examples

scripts/update-cypress-latest.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e # fail on error
23
#
34
# All examples are updated to Cypress latest version
45
#
@@ -8,6 +9,11 @@
89
# npm install pnpm -g
910
# The VScode editor is also used in the last step if available.
1011
#
12+
# First check if the required package managers are installed
13+
./scripts/check-package-manager-npm.sh
14+
./scripts/check-package-managers-other.sh
15+
# then proceed to updating the examples
16+
echo
1117
./scripts/update-cypress-latest-npm.sh
1218
./scripts/update-cypress-latest-other.sh
1319

0 commit comments

Comments
 (0)