Skip to content

Commit

Permalink
update main
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Aug 8, 2023
1 parent b8e6a46 commit 95256d5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/bro.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
# https://github.com/openpeeps/bro

when defined napibuild:
# NAPI Build for Node.js and Bun.js
import denim
import bropkg/engine/[parser, compiler]
from std/sequtils import toSeq

init proc(module: Module) =
proc toCSS(src: string, minify: bool) {.export_napi.} =
let sourcePath = args.get("src").getStr
var p = parseProgram(sourcePath)
var p = parseStylesheet(sourcePath)
if not p.hasErrors:
return %* newCompiler(p.getProgram, args.get("minify").getBool).getCSS()
return %* newCompiler(p.getStylesheet, args.get("minify").getBool).getCSS()
else:
let errors = p.logger.errors.toSeq
assert error($(errors[0]), "BroParsingError")
else:
# CLI Application
when isMainModule:
import kapsis/commands
import kapsis/db
Expand Down Expand Up @@ -58,13 +60,14 @@ else:
$ "ast" `style` `output`:
? "Generates binary AST"

$ "repr" `ast` ["min"]:
$ "repr" `ast` `output` ["min"]:
? "Compiles from binary AST to CSS"

--- "Documentation"
$ "doc" `style`:
$ "doc" `style` ["html", "md", "json"]:
? "Builds a documentation website"

else:
# Bro as a Nimble library
import bropkg/engine/[parser, compiler]
export parser, compiler

0 comments on commit 95256d5

Please sign in to comment.