From d4f133c3d405ae3f14eb6c3d938851ffb5dba356 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 14 Nov 2024 15:52:00 -0500 Subject: [PATCH] rf: Uniformize bidsignore reading between web and Deno --- src/files/deno.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/files/deno.ts b/src/files/deno.ts index f3065a1f..3895a0cd 100644 --- a/src/files/deno.ts +++ b/src/files/deno.ts @@ -151,17 +151,14 @@ async function _readFileTree( */ export async function readFileTree(rootPath: string): Promise { 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 }