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"