-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stream): fixed streams added example
fix #37
- Loading branch information
1 parent
ca7752a
commit 614d89f
Showing
5 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
|
||
import { spawn } from 'child_process' | ||
import { Readable } from 'stream' | ||
|
||
import { Listr } from '@root/index' | ||
import { Logger } from '@utils/logger' | ||
|
||
interface Ctx { | ||
output: string | ||
} | ||
|
||
const logger = new Logger({ useIcons: false }) | ||
|
||
async function main (): Promise<void> { | ||
let task: Listr<Ctx> | ||
|
||
logger.start('Example output from a task.') | ||
|
||
// eslint-disable-next-line prefer-const | ||
task = new Listr<Ctx>([ | ||
{ | ||
title: 'This task will execute.', | ||
task: async (): Promise<Readable> => { | ||
return spawn('ls').stdout | ||
}, | ||
options: { | ||
persistentOutput: true | ||
} | ||
} | ||
], { concurrent: false }) | ||
|
||
try { | ||
const context = await task.run() | ||
logger.success(`Context: ${JSON.stringify(context)}`) | ||
} catch(e) { | ||
logger.fail(e) | ||
} | ||
|
||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters