Skip to content

Commit d5677f6

Browse files
committed
Total should not be set to zero
1 parent 1024acf commit d5677f6

File tree

1 file changed

+3
-3
lines changed
  • packages/gatsby-plugin-sharp/src

1 file changed

+3
-3
lines changed

packages/gatsby-plugin-sharp/src/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function createGatsbyProgressOrFallbackToExternalProgressBar(
1212
const bar = new ProgressBar(
1313
` [:bar] :current/:total :elapsed s :percent ${message}`,
1414
{
15-
total: 0,
15+
total: 1, // if you set this to 0 then you might get 0/0 errors
1616
width: 30,
1717
clear: true,
1818
}
@@ -25,7 +25,7 @@ export function createGatsbyProgressOrFallbackToExternalProgressBar(
2525
},
2626
done() {},
2727
set total(value) {
28-
bar.total = value
28+
bar.total = Math.max(value, 1) || 1 // Do not allow 0, negative numbers, or non-numbers.
2929
},
3030
}
3131
}
@@ -56,7 +56,7 @@ export const createOrGetProgressBar = reporter => {
5656
progressBar.start()
5757
}
5858
pendingImagesCounter += imageCount
59-
progressBar.total = pendingImagesCounter
59+
progressBar.total = Math.max(1, pendingImagesCounter) // 0 will cause 0/0 error
6060
}
6161

6262
// when we create a progressBar for the second time so when .done() has been called before

0 commit comments

Comments
 (0)