Skip to content

Commit

Permalink
rf: Uniformize bidsignore reading between web and Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 14, 2024
1 parent 646abea commit d4f133c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/files/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,14 @@ async function _readFileTree(
*/
export async function readFileTree(rootPath: string): Promise<FileTree> {
const ignore = new FileIgnoreRules([])
try {
const ignoreFile = new BIDSFileDeno(
rootPath,
'.bidsignore',
ignore,
)
ignore.add(await readBidsIgnore(ignoreFile))
} catch (err) {
if (err && typeof err === 'object' && !('code' in err && err.code === 'ENOENT')) {
logger.error(`Failed to read '.bidsignore' file with the following error:\n${err}`)
const tree = await _readFileTree(rootPath, '/', ignore)
const bidsignore = tree.get('.bidsignore')
if (bidsignore) {
try {
ignore.add(await readBidsIgnore(bidsignore as BIDSFile))
} catch (err) {
console.log(`Failed to read '.bidsignore' file with the following error:\n${err}`)
}
}
return _readFileTree(rootPath, '/', ignore)
return tree
}

0 comments on commit d4f133c

Please sign in to comment.