I am working on a CLI with typescript and using enquirer to do so. https://www.npmjs.com/package/enquirer
I have a JSON present.
const a = {
name: 'Mohan',
age: '5',
};
After that I start the Enquirer prompt.
Enquirer.prompt({
name: 'inputVal',
type: 'input',
message: 'Create a Text',
}).then(async response => {
const output: string = (response as any).inputVal;
console.log(output);
});
This prompts for the value and I am trying to write this as the answer
${a.name} has age ${a.age}
This prints on console the following
${a.name} has age ${a.age}
What I want is for console.log to resolve this as
Mohan has age 5
I have tried eval as well but it did not work. Does anyone know how can we do this?