···11+/**
22+ * This example addresses a issue reported in GitHub Actions where `spinner` was excessively writing messages,
33+ * leading to confusion and cluttered output.
44+ * To enhance the CI workflow and provide a smoother experience,
55+ * the following changes have been made only for CI environment:
66+ * - Messages will now only be written when a `spinner` method is called and the message updated, preventing unnecessary message repetition.
77+ * - There will be no loading dots animation, instead it will be always `...`
88+ * - Instead of erase the previous message, action that is blocked during CI, it will just write a new one.
99+ *
1010+ * Issue: https://github.com/natemoo-re/clack/issues/168
1111+ */
1212+import * as p from '@clack/prompts';
1313+1414+const s = p.spinner();
1515+let progress = 0;
1616+let counter = 0;
1717+let loop: NodeJS.Timer;
1818+1919+p.intro('Running spinner in CI environment');
2020+s.start('spinner.start');
2121+new Promise((resolve) => {
2222+ loop = setInterval(() => {
2323+ if (progress % 1000 === 0) {
2424+ counter++;
2525+ }
2626+ progress += 100;
2727+ s.message(`spinner.message [${counter}]`);
2828+ if (counter > 6) {
2929+ clearInterval(loop);
3030+ resolve(true);
3131+ }
3232+ }, 100);
3333+}).then(() => {
3434+ s.stop('spinner.stop');
3535+ p.outro('Done');
3636+});
+1-1
examples/basic/spinner.ts
···33p.intro('spinner start...');
4455const spin = p.spinner();
66-const total = 10000;
66+const total = 6000;
77let progress = 0;
88spin.start();
99