33failed=
44
55which bids-validator
6- if bids-validator --help | grep -q -e ' --config' ; then
7- VALIDATOR_SUPPORTS_CONFIG=yes
6+
7+ if bids-validator --help | grep -q Description; then
8+ VARIANT=" schema"
89else
9- VALIDATOR_SUPPORTS_CONFIG=
10+ VARIANT= " legacy "
1011fi
1112
1213for i in $( ls -d * / | grep -v node_modules) ; do
@@ -22,13 +23,8 @@ for i in $(ls -d */ | grep -v node_modules); do
2223 CMD=" bids-validator ${i%%/ } $VALIDATOR_ARGS "
2324
2425 # Use default configuration unless overridden
25- if [ -n " $VALIDATOR_SUPPORTS_CONFIG " ]; then
26- if [ ! -f ${i%%/ } /.bids-validator-config.json ]; then
27- CMD=" $CMD -c $PWD /bidsconfig.json"
28- fi
29- else
30- # with new one we do not have config so let's get --json and exclude some using jq
31- CMD=" $CMD --json"
26+ if [[ ! ( -f ${i%%/ } /.bids-validator-config.json || $CMD =~ /--config/ ) ]]; then
27+ CMD=" $CMD --config $PWD /${VARIANT} config.json"
3228 fi
3329
3430 # Ignore NIfTI headers except for synthetic dataset
@@ -40,20 +36,7 @@ for i in $(ls -d */ | grep -v node_modules); do
4036
4137 echo " Running " $CMD
4238
43- if [ -n " $VALIDATOR_SUPPORTS_CONFIG " ]; then
44- $CMD || failed+=" $i "
45- else
46- # exit code is not returned correctly anyways and for the best since we need to ignore
47- # ref: https://github.com/bids-standard/bids-validator/issues/1909
48- # NOTE: limit to 1 file per error to not flood screen!
49- errors=$( $CMD 2> /dev/null \
50- | jq ' (.issues | map(select(.severity == "error" and .key != "EMPTY_FILE"))) | map(.files_1 = (.files | if length > 0 then .[0:1] else empty end) | del(.files)) | if length > 0 then . else empty end' \
51- )
52- if [ -n " $errors " ]; then
53- echo -e " $errors " | sed -e ' s,^, ,g'
54- failed+=" $i "
55- fi
56- fi
39+ $CMD || failed+=" $i "
5740done
5841if [ -n " $failed " ]; then
5942 echo " Datasets failed validation: $failed "
0 commit comments