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
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.task/
dist/
.env
/dist
/VERSION
3 changes: 2 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"@std/path": "jsr:@std/path@1.0.8",
"@std/yaml": "jsr:@std/yaml@1.0.5",
"xdg-basedir": "npm:xdg-basedir@5.1.0"
}
},
"unstable": ["raw-imports"]
}
5 changes: 3 additions & 2 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ run = 'deno fmt --check'
run = 'deno lint'

[tasks.'check:type']
depends = 'generate:version'
run = 'deno check src/cli.ts'

[tasks.'generate:version']
run = 'echo "WK_VERSION=${VERSION:-unknown}" > .env'
run = 'echo "${VERSION:-unknown}" > VERSION'

[tasks.build]
depends = [
Expand All @@ -27,5 +28,5 @@ depends = [

[tasks.'build:internal']
depends = 'generate:version'
run = 'deno compile --env-file --allow-all --include src/widget.eta --target {{arg(name="target")}} --output dist/wk-{{arg(name="target")}} src/cli.ts'
run = 'deno compile --allow-all --target {{arg(name="target")}} --output dist/wk-{{arg(name="target")}} src/cli.ts'
hide = true
8 changes: 5 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { type Context, defaultContext } from './types/Context.ts'
import { getKeySymbol, renderPrompt, renderTable } from './ui.ts'
import { parse as parseYaml } from '@std/yaml'
import { parseArgs } from 'node:util'
import VERSION from '../VERSION' with { type: 'text' }
import WIDGET_TEMPLATE from './widget.eta' with { type: 'text' }

const { values: opts } = parseArgs({
options: {
Expand All @@ -27,14 +29,14 @@ const { values: opts } = parseArgs({
})

if (opts.version) {
console.log(Deno.env.get('WK_VERSION') ?? 'unknown')
console.log(VERSION.trim())
Deno.exit(0)
}

if (opts.init !== undefined) {
const eta = new Eta({ views: import.meta.dirname })
const eta = new Eta()

const rendered = eta.render('./widget', {
const rendered = eta.renderString(WIDGET_TEMPLATE, {
wk_path: Deno.execPath(),
bindkey: opts.init,
})
Expand Down