1
我寫使用inquirer.js
節點CLI命令,可能需要相當長一段時間才能完成,所以我想更新UI像這樣結合BottomBar:inquirer.js - 與順序日誌
✓ 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
簡單地設置了作爲BottomBar在官方example描述的和似乎是工作正常。
當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}
的 '正在載入' 線一直在底部,但只顯示第一個日誌。
謝謝!你的修補程序適用於我,我會等待看到公關會發生什麼,然後標記正確:) – daviestar
看起來這已經合併併發布在[v3.0.0](https://github.com/SBoudrias/Inquirer .js文件/發佈/標籤/ V3.0.0) – daviestar