i'm very inexperienced in node.js.
I'm trying to use the code of this answer as a simple user input system (i just need this to read a single line of text), but the script only wait for a input after the rest of the code gets executed (in the case, i can type only after the last console.log is shown). My code:
/**
* @file criaIconeEmoji
* @brief Gera os ícones do Windows a partir de uma pasta com emojis em .svg
*/
var fs = require('fs');
var path = require('path');
var process = require('process');
function prompt(question, callback) {
var stdin = process.stdin,
stdout = process.stdout;
stdin.resume();
stdout.write(question);
stdin.once('data', function (data) {
callback(data.toString().trim());
});
}
var pasta_temporaria = __dirname + "/tmp";
var icones_base_pasta = __dirname + "/base_folder";
var icones_base_biblioteca = __dirname + "/base_library";
var pasta_origem = '';
prompt('Please enter the whole folder path containing the svg assets: ', function (input) {
pasta_origem = input;
});
console.log('Teste');
console.log(pasta_origem);