I am using the invitation library for Node.js and I have this code:
var fs = require('fs'), prompt = require('prompt'), toCreate = toCreate.toLowerCase(), stats = fs.lstatSync('./' + toCreate); if(stats.isDirectory()){ prompt.start(); var property = { name: 'yesno', message: 'Directory esistente vuoi continuare lo stesso? (y/n)', validator: /y[es]*|n[o]?/, warning: 'Must respond yes or no', default: 'no' }; prompt.get(property, function(err, result) { if(result === 'no'){ console.log('Annullato!'); process.exit(0); } }); } console.log("creating ", toCreate); console.log('\nAll done, exiting'.green.inverse);
If the prompt is displayed, it does not seem to block code execution, but execution continues, and the last two messages are displayed using the console, while I still need to answer the question.
Is there any way to block?
Matteo pagliazzi
source share