Skip to content
5 changes: 5 additions & 0 deletions .changeset/famous-turkeys-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clack/prompts": minor
---

Added new `taskLog` prompt for log output which is cleared on success
22 changes: 22 additions & 0 deletions packages/prompts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,26 @@ stream.error((function *() { yield 'Error!'; })());
stream.message((function *() { yield 'Hello'; yield ", World" })(), { symbol: color.cyan('~') });
```

### Task Log

When executing a sub-process or a similar sub-task, `taskLog` can be used to render the output continuously and clear it at the end if it was successful.

```js
import { taskLog } from '@clack/prompts';

const log = taskLog({
message: 'Running npm install'
});

for await (const line of npmInstall()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for await (const line of npmInstall()) {
for await (const line of npmInstall()) {

Not sure if the npmInstall makes it clear enough for the people, but I don't have any better idea

log.message(line);
}

if (success) {
log.success('Done!');
} else {
log.error('Failed!');
}
```

![clack-log-prompts](https://github.com/bombshell-dev/clack/blob/main/.github/assets/clack-logs.png)
Loading