调用bar.tick时,如何使节点进度条不重复自身

问题描述 投票:0回答:1

我正在使用progress包创建一个进度条。

这是我的代码:

bar = new ProgressBar('fetching :bar :current/:total :percent \n :currentItem \n :blocked \n Fetched: :fetched \n Queued: :queued', { total: numRequests });

bar.tick(0, {
    currentItem: `Currently Fetching Text`,
    blocked: 'Blocked text',
    fetched: 'Fecched Text',
    queued: 'Queued Text',
});

在其他应用程序中,我在底部看到一个进度条,用于更新文本,但不会在终端中创建新条目(例如:Yarn的安装栏)。然而,随着progress我每次打电话给bar.tick时都会收到一条新消息。是否可以使用progress只有一条条消息?

node.js terminal progress-bar command-line-interface
1个回答
1
投票

这不是一个很好的解决方案(导致屏幕闪烁......)但是有一个清晰的屏幕console.log

  console.log('\x1Bc');

把它放在bar.tick之前

© www.soinside.com 2019 - 2024. All rights reserved.