| ... | ... | @@ -43,7 +43,7 @@ export class Queue<T, R> { |
| 43 | 43 | get bar() { |
| 44 | 44 | const cached = this.#cachedProgress; |
| 45 | 45 | if (!cached) { |
| 46 | | const bar = this.#cachedProgress = new Progress({ |
| 46 | const bar = (this.#cachedProgress = new Progress({ |
| 47 | 47 | spinner: null, |
| 48 | 48 | text: ({ active }) => { |
| 49 | 49 | const now = performance.now(); |
| ... | ... | @@ -51,8 +51,8 @@ export class Queue<T, R> { |
| 51 | 51 | let n = 0; |
| 52 | 52 | for (const item of active) { |
| 53 | 53 | let itemText = "- " + item.format(now); |
| 54 | | text += `\n` + |
| 55 | | itemText.slice(0, Math.max(0, process.stdout.columns - 1)); |
| 54 | text += |
| 55 | `\n` + itemText.slice(0, Math.max(0, process.stdout.columns - 1)); |
| 56 | 56 | if (n > 10) { |
| 57 | 57 | text += `\n ... + ${active.length - n} more`; |
| 58 | 58 | break; |
| ... | ... | @@ -64,7 +64,7 @@ export class Queue<T, R> { |
| 64 | 64 | props: { |
| 65 | 65 | active: [] as Spinner[], |
| 66 | 66 | }, |
| 67 | | }); |
| 67 | })); |
| 68 | 68 | bar.value = 0; |
| 69 | 69 | return bar; |
| 70 | 70 | } |
| ... | ... | @@ -83,7 +83,10 @@ export class Queue<T, R> { |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | add(args: T) { |
| 86 | | return this.addReturn(args).then(() => {}, () => {}); |
| 86 | return this.addReturn(args).then( |
| 87 | () => {}, |
| 88 | () => {}, |
| 89 | ); |
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | addMany(items: T[]) { |
| ... | ... | @@ -164,11 +167,11 @@ export class Queue<T, R> { |
| 164 | 167 | this.#end(o); |
| 165 | 168 | } |
| 166 | 169 | |
| 167 | | #end( |
| 168 | | { method = this.#passive ? "stop" : "success" }: { |
| 169 | | method?: "success" | "stop"; |
| 170 | | } = {}, |
| 171 | | ) { |
| 170 | #end({ |
| 171 | method = this.#passive ? "stop" : "success", |
| 172 | }: { |
| 173 | method?: "success" | "stop"; |
| 174 | } = {}) { |
| 172 | 175 | const bar = this.#cachedProgress; |
| 173 | 176 | if (this.#errors.length > 0) { |
| 174 | 177 | if (bar) bar.stop(); |
| ... | ... | @@ -287,7 +290,12 @@ export function once<T>(fn: () => Promise<T>): () => Promise<T> { |
| 287 | 290 | let result: T | Promise<T> | null = null; |
| 288 | 291 | return async () => { |
| 289 | 292 | if (result) return result; |
| 290 | | result = await fn(); |
| 293 | try { |
| 294 | result = await (result = fn()); |
| 295 | } catch (err) { |
| 296 | result = null; |
| 297 | throw err; |
| 298 | } |
| 291 | 299 | return result; |
| 292 | 300 | }; |
| 293 | 301 | } |