-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix error caused by the absence of files when starting gulp task #49
Conversation
CI is failing. Always run |
The PR also need a proper descriptive title. |
fixed testing errors
Thanks for the comments. Corrected. |
…b.com/KolinRobinson/gulp-size into fix-sizes-error-if-there-are-no-files
index.js
Outdated
this.prettySize = prettyBytes(this.size); | ||
if (this.size) { | ||
this.prettySize = prettyBytes(this.size); | ||
} |
There was a problem hiding this comment.
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.
Added ternary operator, which in case of undefined will pass 0
This is not what I asked. You need to add the fallback to |
Sorry, this is my first PL. If there are no files, this.size is undefined, which cannot be processed by the prettyBytes () method, which causes a gulp error. In this case, I see a solution either |
This is what I meant. |
Add default value for size if totalSize undefined
Okay. Thanks a lot! |
If there are no files in the folder, then task
.pipe (size ({
'gzip': true,
'pretty': true,
'showFiles': true,
'showTotal': true
}))
gives an error message
TypeError: Expected a finite number, got undefined: undefined
at module.exports (W: \ Freelance \ Easy-webdev-startpack \ node_modules \ pretty-bytes \ index.js: 70: 9)
at Transform._flush (W: \ Freelance \ Easy-webdev-startpack \ node_modules \ gulp-size \ index.js: 115: 21).
This fix solves this error, allowing you not to write additional functionality (in the form of disabling tasks if the folder with files is empty).
Thanks for attention!
Link to the task on which the error is caused: budfy/Easy-webdev-startpack@50ad1fe#diff-6e5c91cb2762eb968b4beffd0b5f42b94a46c4b6b5400195cb64ed98787a09a2