-
Notifications
You must be signed in to change notification settings - Fork 21
fix: use .bids-validator-config.json by default if available. #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…on' if no config has been provided.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #329 +/- ##
=======================================
Coverage 87.18% 87.18%
=======================================
Files 51 51
Lines 3801 3801
Branches 615 615
=======================================
Hits 3314 3314
Misses 477 477
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| const defaultConfig = join(absolutePath, '.bids-validator-config.json') | ||
| try { | ||
| await Deno.lstat(defaultConfig) | ||
| config = JSON.parse(Deno.readTextFileSync(defaultConfig)) | ||
| options.config = defaultConfig | ||
| } catch { | ||
| if (!(err instanceof Deno.errors.NotFound)) { | ||
| throw err; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we did what we do for .bidsignore and pull it out of the tree? We don't need a filesystem hit to check if it's there.
| const defaultConfig = join(absolutePath, '.bids-validator-config.json') | |
| try { | |
| await Deno.lstat(defaultConfig) | |
| config = JSON.parse(Deno.readTextFileSync(defaultConfig)) | |
| options.config = defaultConfig | |
| } catch { | |
| if (!(err instanceof Deno.errors.NotFound)) { | |
| throw err; | |
| } | |
| } | |
| const configFile = tree.get('.bids-validator-config.json') as BIDSFile | |
| if (configFile) { | |
| config = await configFile.text().then((text) => JSON.parse(text)) | |
| } |
We could also use our JSON loader and create an issue. Probably better not to crash...
| let config = {} | ||
| const configFile = dirHandle.find(file => file.name ==='.bids-validator-config.json') | ||
| if (configFile) { | ||
| config = configFile.text().then(text => JSON.parse(text)).catch((err) => { | ||
| alert(`Failed to load ".bids-validator-config.json". \n\nUsing empty configuration object:\n\n${err}`) | ||
| }) | ||
| } | ||
| const fileTree = await fileListToTree(dirHandle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly:
| let config = {} | |
| const configFile = dirHandle.find(file => file.name ==='.bids-validator-config.json') | |
| if (configFile) { | |
| config = configFile.text().then(text => JSON.parse(text)).catch((err) => { | |
| alert(`Failed to load ".bids-validator-config.json". \n\nUsing empty configuration object:\n\n${err}`) | |
| }) | |
| } | |
| const fileTree = await fileListToTree(dirHandle) | |
| const fileTree = await fileListToTree(dirHandle) | |
| let config = {} | |
| const configFile = fileTree.get('.bids-validator-config.json') as BIDSFile | |
| if (configFile) { | |
| config = await configFile.text().then(text => JSON.parse(text)).catch((err) => { | |
| alert(`Failed to load ".bids-validator-config.json". \n\nUsing empty configuration object:\n\n${err}`) | |
| }) | |
| } |
|
Oh, and we probably need to add |
fixes #293
Sins committed in this PR:
alert()