servicemap 0.1.15 → 0.1.16

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.
Files changed (2) hide show
  1. package/bin/servicemap.mjs +18 -5
  2. package/package.json +1 -1
@@ -475,7 +475,13 @@ function runSilent(command, args, options = {}) {
475
475
  });
476
476
  }
477
477
 
478
- async function withSpinner(message, action) {
478
+ function wait(ms) {
479
+ return new Promise((resolvePromise) => {
480
+ setTimeout(resolvePromise, ms);
481
+ });
482
+ }
483
+
484
+ async function withSpinner(message, action, minimumMs = 900) {
479
485
  if (!process.stdout.isTTY) {
480
486
  return action();
481
487
  }
@@ -483,15 +489,22 @@ async function withSpinner(message, action) {
483
489
  const frames = ['◒', '◐', '◓', '◑'];
484
490
  let frame = 0;
485
491
  let dots = '';
486
- process.stdout.write('\x1b[?25l');
487
- const interval = setInterval(() => {
492
+ const startedAt = Date.now();
493
+ const writeFrame = () => {
488
494
  process.stdout.write(`\r\x1b[J${frames[frame]} ${message}${dots}`);
489
495
  frame = (frame + 1) % frames.length;
490
496
  if (frame === 0) dots = dots.length >= 5 ? '' : `${dots}.`;
491
- }, 120);
497
+ };
498
+
499
+ process.stdout.write('\x1b[?25l');
500
+ writeFrame();
501
+ const interval = setInterval(writeFrame, 120);
492
502
 
493
503
  try {
494
- return await action();
504
+ const result = await action();
505
+ const remainingMs = minimumMs - (Date.now() - startedAt);
506
+ if (remainingMs > 0) await wait(remainingMs);
507
+ return result;
495
508
  } finally {
496
509
  clearInterval(interval);
497
510
  process.stdout.write('\r\x1b[J\x1b[?25h');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "servicemap",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Generate an internal service map page or desktop app for a software project.",
5
5
  "type": "module",
6
6
  "bin": {