-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@clack/prompts): new method
spinner.message(msg: string)
- Loading branch information
Showing
4 changed files
with
37 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@clack/prompts': minor | ||
--- | ||
|
||
feat(@clack/prompts): new method `spinner.message(msg: string)` |
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,22 @@ | ||
import * as p from '@clack/prompts'; | ||
|
||
p.intro('spinner start...'); | ||
|
||
const spin = p.spinner(); | ||
const total = 10000; | ||
let progress = 0; | ||
spin.start(); | ||
|
||
new Promise((resolve) => { | ||
const timer = setInterval(() => { | ||
progress = Math.min(total, progress + 100); | ||
if (progress >= total) { | ||
clearInterval(timer); | ||
resolve(true); | ||
} | ||
spin.message(`Loading packages [${progress}/${total}]`); // <=== | ||
}, 100); | ||
}).then(() => { | ||
spin.stop(`Done`); | ||
p.outro('spinner stop...'); | ||
}); |
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