add cli asking for missing vars
This commit is contained in:
@ -32,15 +32,24 @@ export class ScafTemplate {
|
||||
*/
|
||||
async supplyVariables (variablesArg) {
|
||||
this.suppliedVariables = variablesArg
|
||||
this.missingVariables = await this._checkSuppliedVariables(variablesArg)
|
||||
this.missingVariables = await this._checkSuppliedVariables()
|
||||
}
|
||||
|
||||
/**
|
||||
* Will ask for the missing variables by cli interaction
|
||||
*/
|
||||
async askForMissingVariables () {
|
||||
this.missingVariables = await this._checkSuppliedVariables(variablesArg)
|
||||
|
||||
async askCliForMissingVariables () {
|
||||
this.missingVariables = await this._checkSuppliedVariables()
|
||||
let localSmartInteract = new plugins.smartinteract.SmartInteract()
|
||||
for (let missingVariable of this.missingVariables) {
|
||||
localSmartInteract.addQuestions([{
|
||||
name: missingVariable,
|
||||
type: 'input',
|
||||
default: `undefined ${missingVariable}`,
|
||||
message: `What is the value of ${missingVariable}?`
|
||||
}])
|
||||
}
|
||||
let answers = await localSmartInteract.runQueue()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,16 +64,16 @@ export class ScafTemplate {
|
||||
/**
|
||||
* checks if supplied Variables satisfy the template
|
||||
*/
|
||||
private async _checkSuppliedVariables(variablesArg) {
|
||||
private async _checkSuppliedVariables() {
|
||||
let missingVars: string[] = []
|
||||
for (let templateSmartFile of this.templateSmartfileArray) {
|
||||
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
templateSmartFile.contents.toString(),
|
||||
variablesArg
|
||||
this.suppliedVariables
|
||||
)
|
||||
missingVars = plugins.lodash.concat(missingVars, localMissingVars)
|
||||
missingVars = plugins.lodash.uniq(missingVars)
|
||||
}
|
||||
|
||||
return missingVars
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user