You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)){returntrue;}else{return`File does not exists '${args.file_name}'`;}}).action(function(args,callback){constscriptLines=fs.readFileSync(args.file_name).toString().split('\n');for(constlineofscriptLines){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)){returntrue;}else{return`File does not exists '${args.file_name}'`;}}).action(asyncfunction(args,callback){constscriptLines=fs.readFileSync(args.file_name).toString().split('\n');for(constlineofscriptLines){if(line.trim()!==''){awaitvorpal.exec(line);}}callback();});
Any ideas?
The text was updated successfully, but these errors were encountered:
Late to the party here, but I solved this problem using sync-rpc to put my asynchronous operations into a worker thread. It's like magic! The main thread sees synchronous operation while the worker thread does the async stuff. Sounds complicated (for someone like me who never used workers before) but just follow the example in sync-rpc and it's not very difficult.
I tried to write a script runner, but it does not wait for async functions:
Tried that too, but it exits instantly:
Any ideas?
The text was updated successfully, but these errors were encountered: