@mpen/progressbar 0.1.9 → 0.1.10

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/README.md CHANGED
@@ -46,3 +46,5 @@ progress.complete()
46
46
 
47
47
  Use `logLine()` to write messages above the active bar. If work stops early, call
48
48
  `interrupt()` to render the current progress and finish with a newline.
49
+ After `complete()` has been called, `interrupt()` does nothing, so it is safe to
50
+ call in a `finally` block without changing successful output.
package/dist/index.d.mts CHANGED
@@ -169,6 +169,7 @@ declare class ProgressBar {
169
169
  private startTime;
170
170
  private colors;
171
171
  private configuredWidth?;
172
+ private completed;
172
173
  /**
173
174
  * Create a progress bar.
174
175
  *
@@ -250,10 +251,17 @@ declare class ProgressBar {
250
251
  update(progress: number): void;
251
252
  /**
252
253
  * Mark the current output as interrupted and write a newline.
254
+ * Does nothing after [`ProgressBar.complete`]{@link ProgressBar#complete} has been called,
255
+ * so this method can safely be used in a `finally` block.
253
256
  *
254
257
  * @example
255
258
  * ```ts
256
- * progress.interrupt()
259
+ * try {
260
+ * await processFiles()
261
+ * progress.complete()
262
+ * } finally {
263
+ * progress.interrupt()
264
+ * }
257
265
  * ```
258
266
  *
259
267
  * @returns Nothing.
package/dist/index.mjs CHANGED
@@ -124,6 +124,7 @@ var ProgressBar = class {
124
124
  startTime = process.hrtime.bigint();
125
125
  colors;
126
126
  configuredWidth;
127
+ completed = false;
127
128
  constructor(maxOrOptions = 1, width = null, start = true) {
128
129
  const options = typeof maxOrOptions === "object" ? maxOrOptions : {
129
130
  max: maxOrOptions,
@@ -293,15 +294,23 @@ var ProgressBar = class {
293
294
  }
294
295
  /**
295
296
  * Mark the current output as interrupted and write a newline.
297
+ * Does nothing after [`ProgressBar.complete`]{@link ProgressBar#complete} has been called,
298
+ * so this method can safely be used in a `finally` block.
296
299
  *
297
300
  * @example
298
301
  * ```ts
299
- * progress.interrupt()
302
+ * try {
303
+ * await processFiles()
304
+ * progress.complete()
305
+ * } finally {
306
+ * progress.interrupt()
307
+ * }
300
308
  * ```
301
309
  *
302
310
  * @returns Nothing.
303
311
  */
304
312
  interrupt() {
313
+ if (this.completed) return;
305
314
  this.renderNowWithColor("redBright");
306
315
  process.stdout.write("\n");
307
316
  }
@@ -335,6 +344,7 @@ var ProgressBar = class {
335
344
  this.current = this.max;
336
345
  this.renderNowWithColor("blueBright");
337
346
  process.stdout.write("\n");
347
+ this.completed = true;
338
348
  }
339
349
  /**
340
350
  * Whether the progress value has reached the configured maximum.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpen/progressbar",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Terminal progress bar utilities.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -30,8 +30,8 @@
30
30
  "dev": "bun src/dev.ts"
31
31
  },
32
32
  "publishHash": {
33
- "buildDate": "2026-10-04T22:25:30.365-07:00",
34
- "hgChangesetId": "36f79ac2bb8e+",
35
- "sha256": "5870a49673de1536219220bef58b8b98d35b3a223ca37c45e50dcbb138a90d1d"
33
+ "buildDate": "2026-10-05T23:28:33.541-07:00",
34
+ "hgChangesetId": "f6ba09d4d9e4+",
35
+ "sha256": "05e262f9e1a8c071141dcec4f358e3d50917e935921c0bb97e9bb5b4326ed924"
36
36
  }
37
37
  }