@@ -4,7 +4,8 @@ import * as colors from '@std/fmt/colors'
44import { readFileTree } from './files/deno.ts'
55import { fileListToTree } from './files/browser.ts'
66import { FileIgnoreRules } from './files/ignore.ts'
7- import { resolve } from '@std/path'
7+ import { join , resolve } from '@std/path'
8+ import { exists } from "jsr:@std/fs/exists" ;
89import { validate } from './validators/bids.ts'
910import { consoleFormat , resultToJSONStr } from './utils/output.ts'
1011import { setupLogging } from './utils/logger.ts'
@@ -28,7 +29,21 @@ export async function main(): Promise<ValidationResult> {
2829 : undefined
2930 const tree = await readFileTree ( absolutePath , prune , options . preferredRemote )
3031
31- const config = options . config ? JSON . parse ( Deno . readTextFileSync ( options . config ) ) as Config : { }
32+ let config = { }
33+ if ( options . config ) {
34+ config = JSON . parse ( Deno . readTextFileSync ( options . config ) )
35+ } else {
36+ const defaultConfig = join ( absolutePath , '.bids-validator-config.json' )
37+ try {
38+ await Deno . lstat ( defaultConfig )
39+ config = JSON . parse ( Deno . readTextFileSync ( defaultConfig ) )
40+ options . config = defaultConfig
41+ } catch {
42+ if ( ! ( err instanceof Deno . errors . NotFound ) ) {
43+ throw err ;
44+ }
45+ }
46+ }
3247
3348 // Run the schema based validator
3449 const schemaResult = await validate ( tree , options , config )
0 commit comments