Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
fix: fail on coverage threshold.
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Ribó Labrador <elribonazo@gmail.com>
  • Loading branch information
elribonazo committed Dec 16, 2023
1 parent 90ffcf8 commit 1bb3e0c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Array to store the status of each package's coverage command
statuses=()

# Run coverage command in each package
# Run the coverage command for the package
output=$(npm run coverage 2>&1)

# Check if the output contains the specific text you want to check for
if [[ "$output" =~ "does not meet global threshold" ]]; then
echo "Coverage command failed in package"
statuses+=("failed")
else
statuses+=("success")
fi
# Check if any package failed
if [[ "${statuses[*]}" =~ "failed" ]]; then
echo "Coverage failed in one or more packages."
exit 1
else
echo "Coverage passed in all packages."
exit 0
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"clean-packages": "npx lerna run clean && rm -rf node_modules",
"build": "npx lerna run build --stream --include-dependencies",
"coverage": "cd packages/database && npm run coverage",
"coverage": "sh coverage.sh",
"test": "npx lerna run --stream test",
"docs": "npx lerna run --stream docs",
"docs-html": "npx lerna run --stream docs-html",
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test:watch": "NODE_ENV=debug vitest tests/*.test.ts",
"test:debug": "NODE_ENV=debug vitest tests/*.test.ts --inspect-brk --pool threads --poolOptions.threads.singleThread",
"build": "rm -rf build && npx rollup -c rollup/rollup.mjs",
"coverage": "npx vitest run --coverage.enabled && npx istanbul-badges-readme --readmeDir=\"../../\"",
"coverage": "npx vitest run --coverage && npx istanbul-badges-readme --readmeDir=\"../../\"",
"docs": "npx typedoc --options ./typedoc.markdown.cjs --hideGenerator",
"docs-html": "npx typedoc --options ./typedoc.html.cjs --hideGenerator"
},
Expand Down

0 comments on commit 1bb3e0c

Please sign in to comment.