Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Feb 9, 2025
2 parents 5a335f5 + 587842a commit 8534723
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ The BIDS Validator can be run with the [Deno][] runtime
(see [Deno - Installation][] for detailed installation instructions):

```shell
deno run -ERN jsr:@bids/validator
deno run -ERWN jsr:@bids/validator
```

Deno by default sandboxes applications like a web browser.
`-E`, `-R` and `-N` allow the validator to read environment variables,
local files, and network locations.
`-E`, `-R`, '-W', and `-N` allow the validator to read environment variables,
read/write local files, and read network locations.

### Configuration file

Expand Down
8 changes: 4 additions & 4 deletions docs/user_guide/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ In general, there is no need to install Deno applications.
`deno run` allows running from the Javascript Repository:

```sh
deno run -ERN jsr:@bids/validator <dataset>
deno run -ERWN jsr:@bids/validator <dataset>
```

However, you can also install a lightweight script (into `$HOME/.deno/bin`):

```sh
deno install -ERN -g -n bids-validator jsr:@bids/validator
deno install -ERWN -g -n bids-validator jsr:@bids/validator
```

Or compile a bundled binary:

```sh
deno compile -ERN -o bids-validator jsr:@bids/validator
deno compile -ERWN -o bids-validator jsr:@bids/validator
```

## Usage
Expand All @@ -36,7 +36,7 @@ The BIDS Validator takes a single dataset as input:
:sync: run

```sh
deno run -ERN jsr:@bids/validator <dataset>
deno run -ERWN jsr:@bids/validator <dataset>
```

:::
Expand Down
2 changes: 1 addition & 1 deletion src/files/filetree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const nullFile = {
stream: new ReadableStream({
start(controller) {
controller.close()
}
},
}),
text: () => Promise.resolve(''),
readBytes: async (size: number, offset?: number) => new Uint8Array(),
Expand Down
2 changes: 1 addition & 1 deletion src/files/streams.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, assertEquals } from '@std/assert'
import { createUTF8Stream, UnicodeDecodeError } from './streams.ts'
import { streamFromUint8Array, streamFromString } from '../tests/utils.ts'
import { streamFromString, streamFromUint8Array } from '../tests/utils.ts'

Deno.test('createUTF8Stream', async (t) => {
await t.step('should return a TransformStream with UTF8StreamTransformer', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/files/tsv.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { assert, assertEquals, assertNotStrictEquals, assertObjectMatch, assertStrictEquals } from '@std/assert'
import {
assert,
assertEquals,
assertNotStrictEquals,
assertObjectMatch,
assertStrictEquals,
} from '@std/assert'
import { pathToFile } from './filetree.ts'
import { loadTSV } from './tsv.ts'
import { streamFromString } from '../tests/utils.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/issues/datasetIssues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DatasetIssues {
if (!value) {
continue
}
if (key === 'location' && typeof value === "string" && !value.startsWith('/')){
if (key === 'location' && typeof value === 'string' && !value.startsWith('/')) {
const key_ignore = ignore().add(value as string)
found = found.filter((x) => x[key] && key_ignore.ignores(x[key].slice(1, x[key].length)))
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/types/columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ Deno.test('ColumnsMap', async (t) => {
// @ts-expect-error ibid
assertEquals(columns.size, ['0'])
})
await t.step('set columns are permissible', () => {
const columns = new ColumnsMap()
// @ts-expect-error ts thinks size is protected property
columns['set'] = ['0']
// @ts-expect-error ibid
assertEquals(columns.set, ['0'])
})
await t.step('missing columns are undefined', () => {
const columns = new ColumnsMap()
columns['a'] = ['0']
Expand Down
10 changes: 8 additions & 2 deletions src/types/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ const columnMapAccessorProxy = {
prop: symbol | string,
receiver: ColumnsMap,
) {
// Map.size exists, so we need to shadow it with the column contents
if (prop === 'size') return target.get('size')
// Map instance methods/properties that could plasubily be column names:
if (
['clear', 'delete', 'keys', 'set', 'values', 'size'].includes(
prop as string,
)
) {
return target.get(prop as string)
}
const value = Reflect.get(target, prop, receiver)
if (typeof value === 'function') return value.bind(target)
if (prop === Symbol.iterator) return target[Symbol.iterator].bind(target)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/memoize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type WithCache<T> = T & { cache: Map<string, any> }
interface FileLike {
path: string,
path: string
parent: { path: string }
}

Expand Down
2 changes: 1 addition & 1 deletion src/validators/filenameIdentify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Deno.test('test hasMatch', async (t) => {

await t.step('No match', async () => {
const tmpFile = Deno.makeTempFileSync()
const [ dir, base ] = tmpFile.split(SEPARATOR_PATTERN)
const [dir, base] = tmpFile.split(SEPARATOR_PATTERN)
const file = new BIDSFileDeno(dir, `/${base}`, ignore)

const context = new BIDSContext(file)
Expand Down

0 comments on commit 8534723

Please sign in to comment.