File tree Expand file tree Collapse file tree 1 file changed +40
-5
lines changed
Expand file tree Collapse file tree 1 file changed +40
-5
lines changed Original file line number Diff line number Diff line change 1- #! /bin/bash
2-
1+ #! /usr/bin/env bash
32set -euo pipefail
43
5- cd " $( git rev-parse --show-toplevel) "
4+ # Want to install the latest version of the consumer contracts
5+ # Everything existing in workspaces makes this tricky
6+ # 1. make a backup of the original package.json
7+ # 2. patch package.json so references to local packages use "file:" syntax
8+ # 3. install latest versions of consumer contracts into tests directory
9+ # 4. run tests
10+ # 5. clean up local node_modules and backup of package.json
11+
12+ # Go to repo root -> producer package
13+ ROOT_DIR=" $( git rev-parse --show-toplevel) "
14+ PKG_DIR=" $ROOT_DIR /tests/contracts/producer"
15+ cd " $PKG_DIR "
16+
17+ # Backup package.json
18+ cp package.json package.json.bak
19+
20+ # Setup restore on exit
21+ cleanup () {
22+ if [[ -f " package.json.bak" ]]; then
23+ mv package.json.bak package.json
24+ fi
25+
26+ rm -rf node_modules
27+ }
28+ trap cleanup EXIT
29+
30+ # Patch the local package references in package.json
31+ jq '
32+ .dependencies["nhs-notify-web-template-management-utils"] = "file:../../../utils/utils" |
33+ .dependencies["@nhsdigital/nhs-notify-event-schemas-template-management"] = "file:../../../packages/event-schemas"
34+ ' package.json > package.json.tmp && mv package.json.tmp package.json
35+
636
7- npm --workspace tests/contracts/producer install @nhsdigital/notify-core-consumer-contracts@latest --no-save --no-package-lock
37+ # Install isolated from workspace graph
38+ npm install \
39+ @nhsdigital/notify-core-consumer-contracts@latest \
40+ --no-save --no-package-lock \
41+ --workspaces=false
842
9- npm --workspace tests/contracts/producer run test
43+ # Run tests
44+ npm run test
You can’t perform that action at this time.
0 commit comments