Skip to content

Commit

Permalink
feat(deno): Retrieve version from import.meta.url
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jun 10, 2024
1 parent 07cbca5 commit 98360f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bids-validator/src/setup/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LevelName, LogLevelNames } from '../deps/logger.ts'
import { Command, EnumType } from '../deps/cliffy.ts'
import { getVersion } from '../version.ts'

export type ValidatorOptions = {
datasetPath: string
Expand All @@ -19,7 +20,7 @@ export const validateCommand = new Command()
'This tool checks if a dataset in a given directory is compatible with the Brain Imaging Data Structure specification. To learn more about Brain Imaging Data Structure visit http:https://bids.neuroimaging.io',
)
.arguments('<dataset_directory>')
.version('alpha')
.version(getVersion())
.option('--json', 'Output machine readable JSON')
.option(
'-s, --schema <type:string>',
Expand Down
13 changes: 13 additions & 0 deletions bids-validator/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function getVersion(): string {
const url = import.meta.url
if (url.startsWith('file:https://')) {
return 'local'
} else if (url.startsWith('https://deno.land/x/')) {
// Retrieve version X from https://deno.land/x/bids-validator@X/version.ts
return url.split('@')[1].split('/')[0]
} else if (url.startsWith('https://raw.githubusercontent.com')) {
// Retrieve version X from https://raw.githubusercontent.com/bids-standard/bids-validator/X/bids-validator/src/version.ts
return url.split('/bids-validator/')[1]
}
return url
}

0 comments on commit 98360f6

Please sign in to comment.