Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For deno runtime load -s value as local file if non-http #2166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bids-validator/src/setup/loadSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
) as Schema

if (schemaUrl !== undefined) {
let jsonData = {}

Check warning on line 26 in bids-validator/src/setup/loadSchema.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/setup/loadSchema.ts#L26

Added line #L26 was not covered by tests
try {
const jsonResponse = await fetch(schemaUrl)
const jsonData = await jsonResponse.json()
if (typeof Deno !== 'undefined' && !schemaUrl.match(/http(s)?:\/\//)) {
const decoder = new TextDecoder("utf-8");
const data = await Deno.readFile(schemaUrl);
jsonData = JSON.parse(decoder.decode(data))

Check warning on line 31 in bids-validator/src/setup/loadSchema.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/setup/loadSchema.ts#L28-L31

Added lines #L28 - L31 were not covered by tests

} else {
const jsonResponse = await fetch(schemaUrl)
jsonData = await jsonResponse.json()
}

Check warning on line 36 in bids-validator/src/setup/loadSchema.ts

View check run for this annotation

Codecov / codecov/patch

bids-validator/src/setup/loadSchema.ts#L33-L36

Added lines #L33 - L36 were not covered by tests
schema = new Proxy(
jsonData as object,
objectPathHandler,
Expand Down
Loading