-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
InteractiveWriter
with spinner support (#7)
- Loading branch information
Showing
8 changed files
with
551 additions
and
7 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 @@ | ||
import { | ||
InteractiveWriter, | ||
FileWriter, | ||
info, | ||
composeWriters, | ||
success, | ||
} from '..'; | ||
|
||
const delay = (timeout: number) => | ||
new Promise(resolve => setTimeout(resolve, timeout)); | ||
|
||
(async () => { | ||
const { updateSpinner, stopSpinner, startSpinner, print } = composeWriters( | ||
new InteractiveWriter(), | ||
new FileWriter('logs/output.log') | ||
); | ||
|
||
print(info`hello world`); | ||
startSpinner(info`This spinner is spinnin'`, { type: 'bouncingBar' }); | ||
|
||
let interval = setInterval(() => { | ||
print(info`new message ${Date.now()}`); | ||
}, 1000); | ||
|
||
await delay(3000); | ||
updateSpinner(info`This will be a very long lin${'e'.repeat(300)}`); | ||
|
||
await delay(6000); | ||
stopSpinner(success`Finished`); | ||
clearInterval(interval); | ||
|
||
await delay(500); | ||
startSpinner(success`Another spinner`); | ||
|
||
interval = setInterval(() => { | ||
print(info`new message ${Date.now()}`); | ||
}, 1000); | ||
|
||
await delay(5000); | ||
stopSpinner(); | ||
clearInterval(interval); | ||
})(); |
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,4 @@ | ||
{ | ||
"extends": "..", | ||
"include": ["*"] | ||
} |
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
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
Oops, something went wrong.