Skip to content

Commit 0aaee4c

Browse files
authored
feat: add taskLog prompt (#276)
1 parent 7cc8a55 commit 0aaee4c

File tree

5 files changed

+1435
-6
lines changed

5 files changed

+1435
-6
lines changed

.changeset/famous-turkeys-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": minor
3+
---
4+
5+
Added new `taskLog` prompt for log output which is cleared on success

packages/prompts/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,26 @@ stream.error((function *() { yield 'Error!'; })());
226226
stream.message((function *() { yield 'Hello'; yield ", World" })(), { symbol: color.cyan('~') });
227227
```
228228

229+
### Task Log
230+
231+
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.
232+
233+
```js
234+
import { taskLog } from '@clack/prompts';
235+
236+
const log = taskLog({
237+
message: 'Running npm install'
238+
});
239+
240+
for await (const line of npmInstall()) {
241+
log.message(line);
242+
}
243+
244+
if (success) {
245+
log.success('Done!');
246+
} else {
247+
log.error('Failed!');
248+
}
249+
```
250+
229251
![clack-log-prompts](https://github.com/bombshell-dev/clack/blob/main/.github/assets/clack-logs.png)

0 commit comments

Comments
 (0)