MCPcopy Create free account
hub / github.com/EndBug/version-check / readJson

Function readJson

src/main.ts:156–180  ·  view source on GitHub ↗
(file: string, token?: string)

Source from the content-addressed store, hash-verified

154}
155
156async function readJson(file: string, token?: string) {
157 if (isURL(file)) {
158 const headers = token
159 ? {
160 Authorization: `token ${token}`
161 }
162 : {}
163 return (
164 await got({
165 url: file,
166 method: 'GET',
167 headers,
168 responseType: 'json'
169 })
170 ).body
171 } else {
172 const data = readFileSync(file, { encoding: 'utf8' })
173 if (typeof data == 'string')
174 try {
175 return JSON.parse(data)
176 } catch (e) {
177 error(e instanceof Error ? e.stack || e.message : e + '')
178 }
179 }
180}
181
182async function request(url: string) {
183 const headers = token

Callers 2

mainFunction · 0.70
processDirectoryFunction · 0.70

Calls 4

gotFunction · 0.85
errorFunction · 0.85
parseMethod · 0.80
isURLFunction · 0.70

Tested by

no test coverage detected