Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
"./options": "./src/setup/options.ts",
"./issues": "./src/issues/datasetIssues.ts"
},
"exclude": [
"docs/",
"tools/",
"web/",
".*",
"CITATION.cff",
"Dockerfile",
"build.ts",
"local-run"
],
"publish": {
"exclude": [
"**/tests/",
"tools/",
"web/",
".*",
"**/*.test.ts",
"Dockerfile",
"build.ts",
"deno.lock",
"local-run"
"deno.lock"
]
},
"imports": {
Expand Down Expand Up @@ -47,6 +51,8 @@
"semiColons": false,
"singleQuote": true,
"proseWrap": "preserve",
"include": ["src/"]
"include": [
"src/"
]
}
}
41 changes: 21 additions & 20 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/files/deno.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert, assertEquals, assertRejects } from '@std/assert'
import { readAll, readerFromStreamReader } from '@std/io'
import { basename, dirname, fromFileUrl, join } from '@std/path'
import { EOL } from '@std/fs'
import { FileTree } from '../types/filetree.ts'
import type { FileTree } from '../types/filetree.ts'
import { BIDSFileDeno, readFileTree, UnicodeDecodeError } from './deno.ts'
import { requestReadPermission } from '../setup/requestPermissions.ts'
import { FileIgnoreRules } from './ignore.ts'
Expand Down
3 changes: 1 addition & 2 deletions src/files/dwi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parseBvalBvec } from './dwi.ts'

Deno.test('Test bval/bvec parsing', async (t) => {
await t.step('Load 3 bvals', async () => {
const bvals = parseBvalBvec('0 1 2 \n') // Typically ends with " \n"
const bvals = parseBvalBvec('0 1 2 \n') // Typically ends with " \n"
assertEquals(bvals, [['0', '1', '2']])
})
await t.step('Load 3 bvals - missing newline', async () => {
Expand Down Expand Up @@ -32,4 +32,3 @@ Deno.test('Test bval/bvec parsing', async (t) => {
assertEquals(bvecs, [['0', '1', '2'], ['0', '1', '2'], ['0', '1', '2']])
})
})

4 changes: 2 additions & 2 deletions src/files/filetree.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, assertEquals } from '@std/assert'
import { FileIgnoreRules } from './ignore.ts'
import { FileTree } from '../types/filetree.ts'
import type { FileIgnoreRules } from './ignore.ts'
import type { FileTree } from '../types/filetree.ts'
import { filesToTree, pathsToTree } from './filetree.ts'

Deno.test('FileTree generation', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion src/files/filetree.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parse, SEPARATOR_PATTERN } from '@std/path'
import * as posix from '@std/path/posix'
import { BIDSFile, FileTree } from '../types/filetree.ts'
import { type BIDSFile, FileTree } from '../types/filetree.ts'

const nullFile = {
size: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/files/gzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* GZIP
* Module for extracting gzip metadata from a file
*/
import { Gzip } from '@bids/schema/context'
import { BIDSFile } from '../types/filetree.ts'
import type { Gzip } from '@bids/schema/context'
import type { BIDSFile } from '../types/filetree.ts'

/**
* Parse a gzip header from a file
Expand Down
4 changes: 2 additions & 2 deletions src/files/tiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* TIFF
* Module for extracting Tiff metadata
*/
import { Ome, Tiff } from '@bids/schema/context'
import type { Ome, Tiff } from '@bids/schema/context'
import * as XML from '@libs/xml'
import { BIDSFile } from '../types/filetree.ts'
import type { BIDSFile } from '../types/filetree.ts'

function getImageDescription(
dataview: DataView,
Expand Down
4 changes: 2 additions & 2 deletions src/issues/datasetIssues.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nonSchemaIssues } from './list.ts'
import type { Issue, Severity, IssueDefinition, IssueFile } from '../types/issues.ts'
export type { Issue, Severity, IssueDefinition, IssueFile }
import type { Issue, IssueDefinition, IssueFile, Severity } from '../types/issues.ts'
export type { Issue, IssueDefinition, IssueFile, Severity }

// Code is deprecated, return something unusual but JSON serializable
const CODE_DEPRECATED = Number.MIN_SAFE_INTEGER
Expand Down
9 changes: 4 additions & 5 deletions src/issues/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ export const bidsIssues: IssueDefinitionRecord = {
},
CITATION_CFF_VALIDATION_ERROR: {
severity: 'error',
reason:
"The file does not pass validation using the citation.cff standard's schema." +
'https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md'
reason: "The file does not pass validation using the citation.cff standard's schema." +
'https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md',
},
FILE_READ: {
severity: 'error',
reason: 'We were unable to read this file.'
}
reason: 'We were unable to read this file.',
},
}

const hedIssues: IssueDefinitionRecord = {
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export async function main(): Promise<ValidationResult> {
// Run the schema based validator
const schemaResult = await validate(tree, options, config)

let output_string = ""
let output_string = ''
if (options.json) {
output_string = resultToJSONStr(schemaResult)
output_string = resultToJSONStr(schemaResult)
} else {
output_string = consoleFormat(schemaResult, {
verbose: options.verbose ? options.verbose : false,
Expand All @@ -41,7 +41,7 @@ export async function main(): Promise<ValidationResult> {
if (globalThis.Deno) {
Deno.writeTextFileSync(options.outfile, output_string)
} else {
console.error("Output to file only supported in Deno runtime")
console.error('Output to file only supported in Deno runtime')
console.log(output_string)
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/schema/associations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export async function buildAssociations(
try {
file = walkBack(source, inherit, extensions, suffix).next().value
} catch (error) {
if (error && typeof error === 'object' && 'code' in error && error.code === 'MULTIPLE_INHERITABLE_FILES') {
if (
error && typeof error === 'object' && 'code' in error &&
error.code === 'MULTIPLE_INHERITABLE_FILES'
) {
// @ts-expect-error
issues.add(error)
break
Expand Down
5 changes: 4 additions & 1 deletion src/schema/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ export class BIDSContext implements Context {
try {
sidecars = [...walkBack(this.file)]
} catch (error) {
if (error && typeof error === 'object' && 'code' in error && error.code === 'MULTIPLE_INHERITABLE_FILES') {
if (
error && typeof error === 'object' && 'code' in error &&
error.code === 'MULTIPLE_INHERITABLE_FILES'
) {
// @ts-expect-error
this.dataset.issues.add(error)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/fixtures.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BIDSFile, FileTree } from '../types/filetree.ts'
import type { BIDSFile, FileTree } from '../types/filetree.ts'
import { pathsToTree } from '../files/filetree.ts'
import { nullReadBytes } from '../tests/nullReadBytes.ts'

Expand Down
4 changes: 2 additions & 2 deletions src/schema/tables.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GenericRule, GenericSchema, SchemaType, SchemaTypeLike } from '../types/schema.ts'
import { BIDSContext } from './context.ts'
import type { GenericRule, GenericSchema, SchemaType, SchemaTypeLike } from '../types/schema.ts'
import type { BIDSContext } from './context.ts'

interface ColumnDefinition {
Levels?: Record<string, unknown>
Expand Down
2 changes: 1 addition & 1 deletion src/setup/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type ValidatorOptions = {
}

const modalityType = new EnumType<string>(
Object.keys(schema.rules.modalities)
Object.keys(schema.rules.modalities),
)

/** Extendable Cliffy Command with built in BIDS validator options */
Expand Down
2 changes: 1 addition & 1 deletion src/validators/citation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { pathsToTree } from '../files/filetree.ts'
import { BIDSFileDeno } from '../files/deno.ts'
import { citationValidate } from './citation.ts'
import { BIDSContextDataset } from '../schema/context.ts'
import { GenericSchema } from '../types/schema.ts'
import type { GenericSchema } from '../types/schema.ts'
import { loadSchema } from '../setup/loadSchema.ts'

Deno.test('citation validation', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion src/validators/filenameValidate.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FileTree } from '../types/filetree.ts'
import type { FileTree } from '../types/filetree.ts'
import type { GenericSchema } from '../types/schema.ts'
import { assertEquals } from '@std/assert'
import { BIDSContext } from '../schema/context.ts'
Expand Down
8 changes: 4 additions & 4 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export async function getVersion(): Promise<string> {
async function getLocalVersion(path: string): Promise<string> {
// safe.directory setting so we could still operate from another user
try {
const command = new Deno.Command("git", {
const command = new Deno.Command('git', {
args: ['-C', path, '-c', 'safe.directory=*', 'describe', '--tags', '--always'],
})
const { success, stdout } = await command.output();
const { success, stdout } = await command.output()
const description = new TextDecoder().decode(stdout).trim()
return description
} catch(err) {
return ""
} catch (err) {
return ''
}
}

Expand Down