cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2e4bb2af674d25c3cf7c2d0641cd727723387980

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/mock

38lines · modecode

1#!/usr/bin/env bash
2
3set -e
4
5cd "$(dirname "$0")/.."
6
7if [ -n "$1" ]; then
8 URL="$1"
9 shift
10else
11 URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
12fi
13
14# Check if the URL is empty
15if [ -z "$URL" ]; then
16 echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
17 exit 1
18fi
19
20# Run prism mock on the given spec
21if [ "$1" == "--daemon" ]; then
22 npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log &
23
24 # Wait for server to come online
25 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
26 echo -n "."
27 sleep 0.1
28 done
29
30 if grep -q "✖ fatal" ".prism.log"; then
31 cat .prism.log
32 exit 1
33 fi
34
35 echo
36else
37 npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL"
38fi
39