Skip to content

Commit

Permalink
fix: Load .bidsignore in web app
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 7, 2024
1 parent de650a2 commit 09fe27d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions bids-validator/src/files/browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type BIDSFile, FileTree } from '../types/filetree.ts'
import { filesToTree } from './filetree.ts'
import { FileIgnoreRules } from './ignore.ts'
import { FileIgnoreRules, readBidsIgnore } from './ignore.ts'
import { parse, SEPARATOR_PATTERN } from '@std/path'
import * as posix from '@std/path/posix'

Expand Down Expand Up @@ -49,8 +49,13 @@ export class BIDSFileBrowser implements BIDSFile {
/**
* Convert from FileList (created with webkitDirectory: true) to FileTree for validator use
*/
export function fileListToTree(files: File[]): FileTree {
export async function fileListToTree(files: File[]): FileTree {
const ignore = new FileIgnoreRules([])
const tree = new FileTree('/', '/', undefined)
return filesToTree(files.map((f) => new BIDSFileBrowser(f, ignore, tree)))
const root = new FileTree('/', '/', undefined)
const tree = filesToTree(files.map((f) => new BIDSFileBrowser(f, ignore, root)))
const bidsignore = tree.get('.bidsignore')
if (bidsignore) {
ignore.add(await readBidsIgnore(bidsignore))
}
return tree
}
2 changes: 1 addition & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function App() {
const dirHandle = await directoryOpen({
recursive: true,
})
const fileTree = fileListToTree(dirHandle)
const fileTree = await fileListToTree(dirHandle)
setValidation(await validate(fileTree, {}))
}

Expand Down

0 comments on commit 09fe27d

Please sign in to comment.