Vorpal Vantage:我无法以编程方式退出交互式控制台

时间:2018-10-01 10:51:00

标签: javascript node.js vorpal

这怎么了?

const Vantage = require('vantage')

const v = Vantage()
    .delimiter('$test')
    .listen(9000)
    .show()

const close = () => {
    v.exec('exit', () => {
        console.log('DONE')
    })
 }  
setTimeout(close, 1000)

错误:

  

UI提示已在中间提示时调用。在Object.prompt   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/ui.js:131:13)   在Vorpal.vorpal.prompt   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:450:8)   在Vorpal.vorpal.exit   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:1160:12)   在会议上。   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal-commons.js:49:19)   在Vorpal.vorpal._exec   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:846:18)   在Vorpal.vorpal._execQueueItem   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:594:10)   在Vorpal.vorpal._queueHandler   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:579:10)   在Vorpal.vorpal.exec   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/node_modules/vorpal/lib/vorpal.js:554:24)   在Timeout.close上[为_onTimeout]   (/Users/giggioz/Spaghetti/keeper/keeper-giochipiu-delegates/xxx.js:9:7)   在ontimeout(timers.js:380:14)

1 个答案:

答案 0 :(得分:0)

解决方案:

const Vantage = require('vantage')

Vantage()
    .delimiter('$test')
    .listen(9000)
    .show()

const close = () => {
    process.exit(1)
}
setTimeout(close, 1000)