From cafa9108bb2349eb617f5dd8d850b51eee0d9300 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 6 Nov 2025 11:07:52 -0800 Subject: [PATCH] absolute json paths --- src/ribbit.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ribbit.ts b/src/ribbit.ts index 48bab62..814e584 100644 --- a/src/ribbit.ts +++ b/src/ribbit.ts @@ -1,12 +1,17 @@ import { globals } from 'shrimp' import { AnsiUp } from 'ansi_up' +import { join, dirname } from 'path' +import { fileURLToPath } from 'url' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const dataDir = join(__dirname, '..', 'data') const buffer: string[] = [] const NOSPACE_TOKEN = '!!ribbit-nospace!!' const TAG_TOKEN = '!!ribbit-tag!!' -const SELF_CLOSING = new Set(await Bun.file('./data/self-closing.json').json()) -const HTML5_TAGS = await Bun.file('./data/tags.json').json() -const HTML5_ATTRS = new Set(await Bun.file('./data/attrs.json').json()) +const SELF_CLOSING = new Set(await Bun.file(join(dataDir, 'self-closing.json')).json()) +const HTML5_TAGS = await Bun.file(join(dataDir, 'tags.json')).json() +const HTML5_ATTRS = new Set(await Bun.file(join(dataDir, 'attrs.json')).json()) export function wrapCode(code: string): string { return "ribbit do:\n " + code + "\nend"