@@ -22,22 +22,23 @@ function sidecarValueHasHed(sidecarValue: unknown) {
2222 )
2323}
2424
25- let hedSchemas : object | undefined | null = undefined
26-
27- async function setHedSchemas ( datasetDescriptionJson = { } ) {
25+ async function setHedSchemas ( dataset : BIDSContextDataset ) {
26+ if ( dataset . hedSchemas !== undefined ) {
27+ return [ ] as HedIssue [ ]
28+ }
2829 const datasetDescriptionData = new hedValidator . bids . BidsJsonFile (
2930 '/dataset_description.json' ,
30- datasetDescriptionJson ,
31+ dataset . dataset_description ,
3132 null ,
3233 )
3334 try {
34- hedSchemas = await hedValidator . bids . buildBidsSchemas (
35+ dataset . hedSchemas = await hedValidator . bids . buildBidsSchemas (
3536 datasetDescriptionData ,
3637 null ,
3738 )
3839 return [ ] as HedIssue [ ]
3940 } catch ( issueError ) {
40- hedSchemas = null
41+ dataset . hedSchemas = null
4142 return hedValidator . bids . BidsHedIssue . fromHedIssues (
4243 issueError ,
4344 datasetDescriptionData . file ,
@@ -59,22 +60,20 @@ export async function hedValidate(
5960 let hedValidationIssues = [ ] as HedIssue [ ]
6061
6162 try {
62- if ( context . extension == '.tsv' && context . columns ) {
63+ if ( context . extension === '.tsv' && context . columns ) {
6364 if ( ! ( 'HED' in context . columns ) && ! sidecarHasHed ( context . sidecar ) ) {
6465 return
6566 }
66- hedValidationIssues = await setHedSchemas ( context . dataset . dataset_description )
67+ hedValidationIssues = await setHedSchemas ( context . dataset )
6768
6869 file = await buildHedTsvFile ( context )
69- } else if ( context . extension == '.json' && sidecarHasHed ( context . json ) ) {
70- hedValidationIssues = hedValidationIssues = await setHedSchemas (
71- context . dataset . dataset_description ,
72- )
70+ } else if ( context . extension === '.json' && sidecarHasHed ( context . json ) ) {
71+ hedValidationIssues = hedValidationIssues = await setHedSchemas ( context . dataset )
7372 file = buildHedSidecarFile ( context )
7473 }
7574
7675 if ( file ) {
77- hedValidationIssues . push ( ...file . validate ( hedSchemas ) )
76+ hedValidationIssues . push ( ...file . validate ( context . dataset . hedSchemas ) )
7877 }
7978 } catch ( error ) {
8079 context . dataset . issues . add ( {
0 commit comments