- AutoCompleteMultiSelectQuestion
- AutoCompleteQuestion
- ChoiceDefinition
- ConfirmQuestion
- DateQuestion
- FindUpOptions
- ImportDefinition
- InvisibleQuestion
- ListQuestion
- MultiSelectQuestion
- NumberQuestion
- ParsedImport
- PasswordQuestion
- PromptState
- PromptTypeMethod
- PromptsLocales
- SelectQuestion
- TextQuestion
- ToggleQuestion
- UnparsedImport
- AnswerTypes
- Answers
- ChoiceOption
- ChoiceRecords
- ImportMethod
- ImportRecords
- ParsedImportRecords
- PromptType
- PromptsMethod
- Question
- QuestionRecords
- RawImports
- RecordOfImportRecords
- ask
- beforeExit
- bufferStream
- confirm
- fileExists
- findUp
- getFile
- getFileJSON
- getPackageJSON
- interpolateEnv
- isBundledElectronApp
- isDirectory
- isElectronApp
- isImport
- isImportDefinition
- makeBuffer
- mkdir
- parseImports
- prompt
- saveFile
- saveFileJSON
- unlink
▸ beforeExit(callback
): void
Registers a callback function to be executed before the program exits.
Name | Type | Description |
---|---|---|
callback |
() => void |
The callback function to be executed. |
void
• Const
app_data_dir: string
• Const
bashrc_path: string
• Const
home_dir: string
• Const
is_wsl: boolean
= isWsl
• Const
platform: string
• Const
temp_dir: string
• Const
user_config_dir: string
• Const
user_data_dir: string
= app_data_dir
• Const
verbose: number
▸ interpolateEnv(str
, defaultValues?
): string
Interpolate environment variables in the provided string.
Name | Type | Description |
---|---|---|
str |
string |
The string in which to interpolate environment variables. |
defaultValues |
Record <string , string > |
An object representing the default values for variables. |
string
The interpolated string.
▸ isBundledElectronApp(): boolean
Determine if the current process is a bundled Electron app.
boolean
True if the current process is a bundled Electron app, false otherwise.
▸ isElectronApp(): boolean
Determine if the current process is an Electron app.
boolean
True if the current process is an Electron app, false otherwise.
▸ fileExists(filepath
): boolean
Check if a file or directory exists
Name | Type | Description |
---|---|---|
filepath |
PathLike |
The filepath to check |
boolean
- Return true if the file or directory exists, false otherwise
▸ findUp(name
, options?
): any
Search upward from a directory for a file
Name | Type | Description |
---|---|---|
name |
PathLike |
The file to find |
options? |
string | boolean | Partial <FindUpOptions > |
options to be used while finding file |
any
- Return the path of the file, if found. Null if not found
▸ getFile(filepath
, fallback?
): any
| string
Read a file and return its data as string
Name | Type | Description |
---|---|---|
filepath |
PathLike |
The path of the file |
fallback? |
any |
The fallback data if the file doesn't exist |
any
| string
- The data read from the file, or the fallback data if the file doesn't exist
▸ getFileJSON(filepath
, fallback?
): any
| object
Reads a JSON file and return its data as Javascript object
Name | Type | Description |
---|---|---|
filepath |
PathLike |
The path of the file |
fallback? |
any |
The fallback data if the file doesn't exist |
any
| object
- The JSON parsed data, or the fallback data if the file doesn't exist
▸ getPackageJSON(cwd
): any
Gets the contents of the package.json file located in the specified directory.
Name | Type | Description |
---|---|---|
cwd |
string |
The current working directory. |
any
- The contents of the package.json file as a JSON object.
▸ isDirectory(filepath
): boolean
Check if a path is directory
Name | Type | Description |
---|---|---|
filepath |
PathLike |
The path to check |
boolean
- Return true if the path is a directory, false otherwise
▸ mkdir(dir_path
, recursive?
): void
Create a new directory
Name | Type | Default value | Description |
---|---|---|---|
dir_path |
PathLike |
undefined |
The path of the directory to create |
recursive? |
boolean |
true |
Whether to create directories recursively |
void
▸ saveFile(filepath
, content
, options?
): void
Write data to a file
Name | Type | Default value | Description |
---|---|---|---|
filepath |
PathOrFileDescriptor |
undefined |
The path of the file |
content |
string | ArrayBufferView |
undefined |
The content to write |
options? |
WriteFileOptions |
'utf8' |
options to be used while writing file |
void
- Return nothing
▸ saveFileJSON(filepath
, content
, options?
): void
Write a Javascript object to a JSON file
Name | Type | Default value | Description |
---|---|---|---|
filepath |
PathOrFileDescriptor |
undefined |
The path of the file |
content |
any |
undefined |
The object to write |
options? |
WriteFileOptions |
'utf8' |
options to be used while writing file |
void
- Return nothing
▸ unlink(filepath
): void
Delete a file
Name | Type | Description |
---|---|---|
filepath |
PathLike |
The path of the file |
void
Ƭ ImportMethod<Args
, Results
>: (...args
: Args
[]) => Promise
<Results
> | Results
Name | Type |
---|---|
Args |
any |
Results |
any |
▸ (...args
): Promise
<Results
> | Results
Name | Type |
---|---|
...args |
Args [] |
Promise
<Results
> | Results
Ƭ ImportRecords<I
>: Record
<string
, I
| ImportDefinition
<I
>>
Name | Type |
---|---|
I |
extends ImportMethod = ImportMethod |
Ƭ ParsedImportRecords<I
>: Record
<string
, ParsedImport
<I
>>
Name | Type |
---|---|
I |
extends ImportMethod = ImportMethod |
Ƭ RawImports<I
>: ImportRecords
<I
> | RecordOfImportRecords
<I
> | any
Name | Type |
---|---|
I |
extends ImportMethod = ImportMethod |
Ƭ RecordOfImportRecords<I
>: Record
<string
, ImportRecords
<I
>>
Name | Type |
---|---|
I |
extends ImportMethod = ImportMethod |
▸ isImport(data
): boolean
Checks whether a given data is of "import" type.
Name | Type | Description |
---|---|---|
data |
any |
The data to be checked. |
boolean
- Returns true if provided data is an import type.
▸ isImportDefinition(data
): boolean
Checks whether a given data is of "import definition" type.
Name | Type | Description |
---|---|---|
data |
any |
The data to be checked. |
boolean
- Returns true if provided data is an import definition type.
▸ parseImports<I
>(imports
, parent?
): ParsedImportRecords
<I
>
Parse provided imports and prepares a record of it.
Name | Type |
---|---|
I |
extends ImportMethod <any , any > = ImportMethod <any , any > |
Name | Type | Description |
---|---|---|
imports |
any |
The raw imports to be parsed. |
parent? |
string |
The parent name. |
▸ bufferStream(readable
): Promise
<Buffer
>
Buffers the data from a Readable stream and returns a Promise that resolves to a Buffer.
Name | Type | Description |
---|---|---|
readable |
Readable |
The Readable stream to be buffered. |
Promise
<Buffer
>
A Promise that resolves to a Buffer containing all the data from the Readable stream.
▸ makeBuffer(content
): Buffer
Creates a new Buffer object from the given content.
Name | Type | Description |
---|---|---|
content |
string |
The content to be used for creating the Buffer. |
Buffer
- The created Buffer object.
Ƭ AnswerTypes: Date
| boolean
| number
| string
Ƭ Answers: Record
<string
, string
>
Ƭ ChoiceOption: ChoiceDefinition
| string
Ƭ ChoiceRecords: Record
<string
, ChoiceOption
>
Ƭ PromptType: "autocomplete"
| "autocompleteMultiselect"
| "confirm"
| "date"
| "invisible"
| "list"
| "multiselect"
| "number"
| "password"
| "select"
| "text"
| "toggle"
Ƭ PromptsMethod: (prev
: string
, answers
: Answers
, previousQuestion
: Question
) => Promise
<string
> | string
▸ (prev
, answers
, previousQuestion
): Promise
<string
> | string
Name | Type |
---|---|
prev |
string |
answers |
Answers |
previousQuestion |
Question |
Promise
<string
> | string
Ƭ Question: AutoCompleteMultiSelectQuestion
| AutoCompleteQuestion
| ConfirmQuestion
| DateQuestion
| InvisibleQuestion
| ListQuestion
| MultiSelectQuestion
| NumberQuestion
| PasswordQuestion
| SelectQuestion
| TextQuestion
| ToggleQuestion
Ƭ QuestionRecords: Record
<string
, Question
>
▸ ask(question
, defaultAnswer?
): Promise
<any
>
Prompt the user for input using Prompts.
Name | Type | Description |
---|---|---|
question |
string |
The question to be asked to the user. |
defaultAnswer? |
string | boolean |
The default answer for the question. |
Promise
<any
>
- A promise that will be resolved with the answer.
See
https://github.com/terkelg/prompts
▸ ask(question
, options?
): Promise
<any
>
Prompt the user for input using Prompts.
Name | Type | Description |
---|---|---|
question |
string |
The question to be asked to the user. |
options? |
Partial <Question > |
The options for the question. |
Promise
<any
>
- A promise that will be resolved with the answer.
See
https://github.com/terkelg/prompts
▸ confirm(question
, defaultAnswer?
): Promise
<boolean
>
Prompt the user for confirmation using Prompts with a default boolean answer.
Name | Type | Description |
---|---|---|
question |
string |
The question to be asked to the user. |
defaultAnswer? |
boolean |
The default answer for the question. |
Promise
<boolean
>
- A promise that will be resolved with the answer.
See
https://github.com/terkelg/prompts
▸ confirm(question
, options?
): Promise
<boolean
>
Prompt the user for confirmation using Prompts with question options.
Name | Type | Description |
---|---|---|
question |
string |
The question to be asked to the user. |
options? |
Partial <Question > |
The options for the question. |
Promise
<boolean
>
- A promise that will be resolved with the answer.
See
https://github.com/terkelg/prompts
▸ prompt(questions
): Promise
<Answers
>
Prompts the user with questions and returns the answers as a promise.
Name | Type | Description |
---|---|---|
questions |
QuestionRecords | Question [] |
The questions to prompt the user with. |
Promise
<Answers
>
- A promise that resolves with the answers provided by the user.