Skip to content

Commit

Permalink
export types
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvr committed Mar 20, 2024
1 parent b2ed27a commit 2315f5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@mattvr/dgen",
"version": "0.0.2",
"exports": "./mod.ts"
}
15 changes: 13 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Filter } from "https://deno.land/x/[email protected]/src/environment.ts";
import { parse as parseJsonc } from "https://deno.land/[email protected]/jsonc/parse.ts";
import { parseArgs } from "https://deno.land/[email protected]/cli/parse_args.ts";

type CodegenArgs = {
/**
* Arguments object to pass to the codegen(...) function.
*/
export type CodegenArgs = {
/**
* Full path to the template file (vento .vto template)
*/
Expand Down Expand Up @@ -74,7 +77,10 @@ type CodegenArgs = {
error?: (err: Error) => void;
}

const DEFAULT_ARGS: Partial<CodegenArgs> = {
/**
* Default arguments for codegen(...) function
*/
export const DEFAULT_ARGS: Partial<CodegenArgs> = {
templateVtoPath: "template.vto",
filters: {
upper: (str: string) => str.toUpperCase(),
Expand All @@ -89,6 +95,11 @@ const DEFAULT_ARGS: Partial<CodegenArgs> = {
flags: ['fmt', 'check', 'print_info'],
};

/**
* Generate code from a Vento template and optional processor file
* @param args Arguments object to pass to the code
* @returns Generated code as a string
*/
export const codegen = async (args: CodegenArgs): Promise<string> => {
const startTime = performance.now();
const {
Expand Down

0 comments on commit 2315f5c

Please sign in to comment.