Skip to content

Commit

Permalink
Merge pull request #2032 from effigies/fix/deno-inspect
Browse files Browse the repository at this point in the history
fix(web): Use JSON.stringify when Deno.inspect is unavailable
  • Loading branch information
rwblair authored Jul 30, 2024
2 parents ccfd5db + 398a8cf commit 68f247a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bids-validator/src/schema/applyRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ export function evalColumns(
sidecarDefinedTypeCheck(columnObject.definition, value, schema)
}

const inspect = typeof Deno !== 'undefined' ? Deno.inspect : (x: any) => JSON.stringify(x, null, 2)

if (
name in context.sidecar && context.sidecar[name] &&
typeof (context.sidecar[name]) === 'object'
Expand All @@ -264,7 +266,7 @@ export function evalColumns(
} else {
context.issues.addNonSchemaIssue('TSV_COLUMN_TYPE_REDEFINED', [{
...context.file,
evidence: `'${name}' redefined with sidecar ${Deno.inspect(context.sidecar[name])}`,
evidence: `'${name}' redefined with sidecar ${inspect(context.sidecar[name])}`,
}])
}
}
Expand All @@ -280,7 +282,7 @@ export function evalColumns(
context.issues.addNonSchemaIssue(error_code, [
{
...context.file,
evidence: `'${value}' ${Deno.inspect(columnObject)}`,
evidence: `'${value}' ${inspect(columnObject)}`,
},
])
break
Expand Down

0 comments on commit 68f247a

Please sign in to comment.