Plugins: inquirer
Inquirer plugin
This plugin uses inquirer library
Functionality:
check hook
This hook is the responsible to run all functionality explained on inquire. Use prompts parameter from config.json to be configured.
NOTE: Is possible to disable this hook with using --disablePrompts when you run pisco command line.
1. inquire(name) addon
this.inquire(name)
returns a promise and push all parameters asked to this.params object.
Param | Type | Optional | Description |
---|---|---|---|
name | String | No | Name of the parameter inside this.params to use as prompts |
this.inquire(name)
launch inquire based in piscosour configuration. See inquire for more information.
Example:
In index.js of the step.
this.inquire('promptsCordova')
.then(() => {
if (this.params.doRestore) {
// Do stuff
}
});
in config.json of the step
"promptsCordova": [
{
"type": "confirm",
"name": "doRestore",
"default": true,
"required": true,
"message": "Plugins and/or platforms already exists, do you want to regenerate it?"
}
]
Note that is possible to define promptsCordova inside index.js this way:
this.params.promptsCordova = [
{
"type": "confirm",
"name": "doRestore",
"default": true,
"required": true,
"message": "Plugins and/or platforms already exists, do you want to regenerate it?"
}
];
this.inquire('promptsCordova')
.then(() => {
if (this.params.doRestore) {
// Do stuff
}
});
2. promptArgs() addon
this.promptArgs(array)
returns an Array
with the list of configured inquirer prompts according to the command line format such as:
['--param1', 'value1', '--param2', 'value2', '...']
Param | Type | Description |
---|---|---|
initialArray | Array | An initial array of parameters/values where parameters/values of the configuration are going to be added |
Example:
{
"prompts": [
{
"type": "input",
"name": "param1",
"message": "#randomMessage"
}
]
}
run: function(resolve, reject) {
return this.execute('echo', this.promptArgs(['--sample', 'valueSample']))
.then(resolve, reject);
}
Where this.promptArgs(['--sample', 'valueSample'])
will return an array:
[
'--sample', 'valueSample',
'--param1', 'valueInquirer'
]