servicemap 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/servicemap.mjs +16 -7
- package/package.json +1 -1
package/bin/servicemap.mjs
CHANGED
|
@@ -425,19 +425,28 @@ function wait(ms) {
|
|
|
425
425
|
});
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
async function withSpinner(message, action, minimumMs =
|
|
429
|
-
if (!process.stdout.isTTY) {
|
|
430
|
-
return action();
|
|
431
|
-
}
|
|
432
|
-
|
|
428
|
+
async function withSpinner(message, action, minimumMs = 1400) {
|
|
433
429
|
const frames = ['◒', '◐', '◓', '◑'];
|
|
434
430
|
let frame = 0;
|
|
435
431
|
let dots = '';
|
|
436
432
|
const startedAt = Date.now();
|
|
437
|
-
const
|
|
438
|
-
|
|
433
|
+
const nextText = () => {
|
|
434
|
+
const text = `${dim('│')} ${frames[frame]} ${message}${dots}`;
|
|
439
435
|
frame = (frame + 1) % frames.length;
|
|
440
436
|
if (frame === 0) dots = dots.length >= 5 ? '' : `${dots}.`;
|
|
437
|
+
return text;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
if (!process.stdout.isTTY) {
|
|
441
|
+
console.log(nextText());
|
|
442
|
+
const result = await action();
|
|
443
|
+
const remainingMs = minimumMs - (Date.now() - startedAt);
|
|
444
|
+
if (remainingMs > 0) await wait(remainingMs);
|
|
445
|
+
return result;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const writeFrame = () => {
|
|
449
|
+
process.stdout.write(`\r\x1b[J${nextText()}`);
|
|
441
450
|
};
|
|
442
451
|
|
|
443
452
|
process.stdout.write('\x1b[?25l');
|