Skip to content

Commit

Permalink
fix(win): Use posix.join in constructing FileTrees
Browse files Browse the repository at this point in the history
The internal representation of file trees uses relative paths. For
simplicity, we should ensure that these always use POSIX separators.
  • Loading branch information
effigies committed Jun 9, 2024
1 parent 7749bf0 commit 48ad192
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions bids-validator/src/deps/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
basename,
dirname,
extname,
posix,
fromFileUrl,
parse,
SEPARATOR_PATTERN,
Expand Down
4 changes: 2 additions & 2 deletions bids-validator/src/files/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BIDSFile } from '../types/file.ts'
import { FileTree } from '../types/filetree.ts'
import { FileIgnoreRules } from './ignore.ts'
import { parse, join, SEPARATOR_PATTERN } from '../deps/path.ts'
import { parse, posix, SEPARATOR_PATTERN } from '../deps/path.ts'

/**
* Browser implement of BIDSFile wrapping native File/FileList types
Expand Down Expand Up @@ -68,7 +68,7 @@ export function fileListToTree(files: File[]): Promise<FileTree> {
} else {
// Otherwise make a new level and continue if needed
const newTree = new FileTree(
join(currentLevelTree.path, level),
posix.join(currentLevelTree.path, level),
level,
currentLevelTree,
)
Expand Down
6 changes: 3 additions & 3 deletions bids-validator/src/files/deno.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Deno specific implementation for reading files
*/
import { join, basename } from '../deps/path.ts'
import { posix, join, basename } from '../deps/path.ts'
import { BIDSFile } from '../types/file.ts'
import { FileTree } from '../types/filetree.ts'
import { requestReadPermission } from '../setup/requestPermissions.ts'
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function _readFileTree(
if (dirEntry.isFile || dirEntry.isSymlink) {
const file = new BIDSFileDeno(
rootPath,
join(relativePath, dirEntry.name),
posix.join(relativePath, dirEntry.name),
ignore,
)
// For .bidsignore, read in immediately and add the rules
Expand All @@ -134,7 +134,7 @@ export async function _readFileTree(
if (dirEntry.isDirectory) {
const dirTree = await _readFileTree(
rootPath,
join(relativePath, dirEntry.name),
posix.join(relativePath, dirEntry.name),
ignore,
tree,
)
Expand Down

0 comments on commit 48ad192

Please sign in to comment.