From c02e1f0cb15a828d2d6dcb4a68b7a4e7be4d8c84 Mon Sep 17 00:00:00 2001 From: Ross Blair Date: Tue, 8 Oct 2024 17:07:46 -0500 Subject: [PATCH] web build did not like fs import at top of src/files/deno. Conditionally load library. Maybe better off just attempting text call and seeing if it errors out. --- bids-validator/src/files/deno.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bids-validator/src/files/deno.ts b/bids-validator/src/files/deno.ts index 346d7f07f..07a499546 100644 --- a/bids-validator/src/files/deno.ts +++ b/bids-validator/src/files/deno.ts @@ -2,7 +2,6 @@ * Deno specific implementation for reading files */ import { basename, join } from '@std/path' -import { existsSync } from '@std/fs' import * as posix from '@std/path/posix' import { type BIDSFile, FileTree } from '../types/filetree.ts' import { requestReadPermission } from '../setup/requestPermissions.ts' @@ -150,13 +149,16 @@ async function _readFileTree( */ export async function readFileTree(rootPath: string): Promise { const ignore = new FileIgnoreRules([]) - if (existsSync(join(rootPath, '.bidsignore'))) { - const ignoreFile = new BIDSFileDeno( - rootPath, - '.bidsignore', - ignore, - ) - ignore.add(await readBidsIgnore(ignoreFile)) + if (globalThis.Deno) { + import { existsSync } from '@std/fs' + if (existsSync(join(rootPath, '.bidsignore'))) { + const ignoreFile = new BIDSFileDeno( + rootPath, + '.bidsignore', + ignore, + ) + ignore.add(await readBidsIgnore(ignoreFile)) + } } return _readFileTree(rootPath, '/', ignore) }