fork of hey-api/openapi-ts because I need some additional things

Merge pull request #1755 from Matsuuu/openapi-ts-watch-no-head

authored by

Lubos and committed by
GitHub
5bdda409 f14b57bb

+20 -8
+5
.changeset/selfish-nails-fail.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix: Wrap the GET request in watch mode with try-catch to prevent crashes on no-head watch targets
+15 -8
packages/openapi-ts/src/getSpec.ts
··· 109 109 } 110 110 } 111 111 112 - const fileRequest = await sendRequest({ 113 - init: { 114 - method: 'GET', 115 - }, 116 - timeout, 117 - url: resolvedInput.path, 118 - }); 119 - response = fileRequest.response; 112 + try { 113 + const fileRequest = await sendRequest({ 114 + init: { 115 + method: 'GET', 116 + }, 117 + timeout, 118 + url: resolvedInput.path, 119 + }); 120 + response = fileRequest.response; 121 + } catch (ex) { 122 + return { 123 + error: 'not-ok', 124 + response: new Response(ex.message), 125 + }; 126 + } 120 127 121 128 if (!response.ok) { 122 129 // assume the server is no longer running