Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error caused by the absence of files when starting gulp task #49

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ module.exports = (options = {}) => {
})();
}, function (callback) {
this.size = totalSize.values().next().value;
this.prettySize = prettyBytes(this.size);
if (this.size) {
this.prettySize = prettyBytes(this.size);
}
Copy link
Owner

@sindresorhus sindresorhus Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettySize is documented to always exist, so it should fall back to 0 for this.size. Just do a ternary.


if (!(fileCount === 1 && options.showFiles) && hasSize(totalSize) && fileCount > 0 && options.showTotal) {
log(chalk.green('all files'), totalSize);
Expand Down