2017-01-22 51 views
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.logconsole.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} 

的 '正在載入' 線一直在底部,但只顯示第一個日誌。

回答

1

這似乎是Inquirer.js中的一個問題。當從0.12.0更新到更新的基於ES6 Promise的界面時,我遇到了它。

我開了一個問題: https://github.com/SBoudrias/Inquirer.js/issues/485

,放在一個固定拉請求: https://github.com/SBoudrias/Inquirer.js/pull/486

希望它被接受。

+0

謝謝!你的修補程序適用於我,我會等待看到公關會發生什麼,然後標記正確:) – daviestar

+0

看起來這已經合併併發布在[v3.0.0](https://github.com/SBoudrias/Inquirer .js文件/發佈/標籤/ V3.0.0) – daviestar