Open

Description
I tried to write a script runner, but it does not wait for async functions:
vorpal
.command('run <file_name>', 'Run a script file')
.validate(function (args) {
if (fs.existsSync(args.file_name)) {
return true;
} else {
return `File does not exists '${args.file_name}'`;
}
})
.action(function (args, callback) {
const scriptLines = fs.readFileSync(args.file_name).toString().split('\n');
for (const line of scriptLines) {
if (line.trim() !== '') {
vorpal.execSync(line);
}
}
callback();
});
Tried that too, but it exits instantly:
vorpal
.command('run <file_name>', 'Run a script file')
.validate(function (args) {
if (fs.existsSync(args.file_name)) {
return true;
} else {
return `File does not exists '${args.file_name}'`;
}
})
.action(async function (args, callback) {
const scriptLines = fs.readFileSync(args.file_name).toString().split('\n');
for (const line of scriptLines) {
if (line.trim() !== '') {
await vorpal.exec(line);
}
}
callback();
});
Any ideas?
Metadata
Metadata
Assignees
Labels
No labels