cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2157ac0defa017fe65df1d07e909c7d030f77594

Branches

Tags

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

Clone

HTTPS

Download ZIP

scripts/mock

34lines · modecode

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