Simplify js api
This commit is contained in:
Vendored
+22
-25
@@ -5,42 +5,39 @@
|
||||
*/
|
||||
declare function echo(message: string): void
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
declare function prompt(text: string, def?: string): string
|
||||
declare interface prompt {
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
declare function promptBoolean(text: string, def?: boolean): boolean
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
string(text: string, def?: string): string
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
boolean(text: string, def?: boolean): boolean
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a template
|
||||
*
|
||||
* @param name - The template name
|
||||
* @param context - The template context
|
||||
* @param output - The output path, if absent, default to the template name
|
||||
*/
|
||||
declare function render(name: string, context: any): string
|
||||
|
||||
/**
|
||||
* Write a string to a file
|
||||
*
|
||||
* @param input - The content of the file
|
||||
* @param output - The output path
|
||||
*/
|
||||
declare function write(input: string, output: string): void
|
||||
declare function render(name: string, context: any, output?: string): string
|
||||
|
||||
/**
|
||||
* Copy a file
|
||||
*
|
||||
* @param input - The input path
|
||||
* @param output - The output path
|
||||
* @param output - The output path, if absent, default to the input path
|
||||
*/
|
||||
declare function copy(input: string, output: string): void
|
||||
declare function copy(input: string, output?: string): void
|
||||
@@ -1,7 +1,7 @@
|
||||
echo("Example")
|
||||
|
||||
const name = prompt("Project name")
|
||||
const name = prompt.string("Project name")
|
||||
|
||||
const ctx = {name: name}
|
||||
|
||||
write(render("README.md", ctx), "README.md")
|
||||
render("README.md", ctx)
|
||||
Reference in New Issue
Block a user