Skip to content

Commit

Permalink
feat(build): Tag version on build
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Jun 10, 2024
1 parent 789ff09 commit 02f8128
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion bids-validator/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as esbuild from 'https://deno.land/x/esbuild@v0.20.2/mod.js'
import { parse } from 'https://deno.land/std@0.223.0/flags/mod.ts'
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader@0.10"
import * as path from "https://deno.land/std@0.223.0/path/mod.ts"
import { getVersion } from './src/version.ts'


function getModuleDir(importMeta: ImportMeta): string {
Expand All @@ -24,14 +25,34 @@ const flags = parse(Deno.args, {
default: { minify: false },
})

const version = await getVersion()

let versionPlugin = {
name: 'version',
setup(build: esbuild.PluginBuild) {
build.onResolve({ filter: /\.git-meta\.json/ }, (args) => ({
path: args.path,
namespace: 'version-ns',
}))

build.onLoad({ filter: /.*/, namespace: 'version-ns' }, () => ({
contents: JSON.stringify({ description: version }),
loader: 'json',
}))
},
}

const result = await esbuild.build({
format: 'esm',
entryPoints: [MAIN_ENTRY, CLI_ENTRY],
bundle: true,
outdir: path.join('dist','validator'),
minify: flags.minify,
target: ['chrome109', 'firefox109', 'safari16'],
plugins: [...denoPlugins()],
plugins: [
versionPlugin,
...denoPlugins(),
],
allowOverwrite: true,
sourcemap: flags.minify ? false : 'inline',
})
Expand Down

0 comments on commit 02f8128

Please sign in to comment.