const { stdin, stdout } = process;
// Prompt function
function prompt(question) {
return new Promise((resolve, reject) => {
stdin.resume();
stdout.write(question);
stdin.on('data', data => resolve(data.toString().trim()));
stdin.on('error', err => reject(err));
});
}
// Init
async function init() {
try {
let value = await prompt('Please type something')
console.log(value)
stdin.pause();
} catch(error) {
console.log("There's an error!");
console.log(error);
}
process.exit();
}
init();
/**
* Read Files Content
*/
function readFileContents(dir) {
const files = [];
fs.readdirSync(dir).forEach(filename => {
const data = fs.readFileSync(dir+'/'+filename, 'utf-8')
files.push(data)
});
return files;
}
function copyFolderSync(from, to) {
fs.mkdirSync(to);
fs.readdirSync(from).forEach(element => {
if (fs.lstatSync(path.join(from, element)).isFile()) {
fs.copyFileSync(path.join(from, element), path.join(to, element));
} else {
copyFolderSync(path.join(from, element), path.join(to, element));
}
});
}