3
3
failed=
4
4
5
5
which 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"
8
9
else
9
- VALIDATOR_SUPPORTS_CONFIG=
10
+ VARIANT= " legacy "
10
11
fi
11
12
12
13
for i in $( ls -d * / | grep -v node_modules) ; do
@@ -22,13 +23,8 @@ for i in $(ls -d */ | grep -v node_modules); do
22
23
CMD=" bids-validator ${i%%/ } $VALIDATOR_ARGS "
23
24
24
25
# 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"
32
28
fi
33
29
34
30
# Ignore NIfTI headers except for synthetic dataset
@@ -40,20 +36,7 @@ for i in $(ls -d */ | grep -v node_modules); do
40
36
41
37
echo " Running " $CMD
42
38
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 "
57
40
done
58
41
if [ -n " $failed " ]; then
59
42
echo " Datasets failed validation: $failed "
0 commit comments