我正在使用inquirer.js编写Node CLI命令,这可能需要相当长的时间才能完成,所以我正在尝试更新UI,如下所示:
✓ Thing A complete
✓ Thing B complete
✓ Thing C complete
⠹ Loading...
{display json result}(其中“正在加载...”留在底部,日志在它们完成时出现)。
简化后,该命令的结构如下:
ui.startLoader()
thingA()
.then((res) => {
ui.log('✓ Thing A complete')
return res
})
.then((res) => {
return res.reduce(thingB, Promise.resolve())
})
.then((res) => {
ui.log('✓ Thing B complete')
return res
})
.then((res) => {
return res.reduce(thingC, Promise.resolve())
})
.then((res) => {
ui.log('✓ Thing C complete')
return res
})
.then(ui.json)
.catch(console.log)
.then(ui.exit)ui.startloader只需按照官方example中的描述设置BottomBar,并且看起来运行良好。
当ui.log为console.log('\n' . text)时,我的输出为:
⠋ Loading...
✓ Thing A complete
⠹ Loading...
✓ Thing B complete
⠴ Loading...
✓ Thing C complete
{display json result}当ui.log是inquirer.js的BottomBar.log.write(text)时,我的输出是:
✓ Thing A complete
⠹ Loading...
{display json result}“正在加载...”行保留在底部,但只显示第一个日志。
发布于 2017-01-23 20:36:25
这似乎是Inquirer.js中的一个问题。当我从0.12.0升级到更新的基于ES6 Promise的界面时,我遇到了这个问题。
我已经打开了一个问题:https://github.com/SBoudrias/Inquirer.js/issues/485
并放入修复的拉取请求:https://github.com/SBoudrias/Inquirer.js/pull/486
希望它能被接受。
https://stackoverflow.com/questions/41791589
复制相似问题