-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "@mattvr/dgen", | ||
"version": "0.0.2", | ||
"exports": "./mod.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
*/ | ||
|
@@ -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(), | ||
|
@@ -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 { | ||
|