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 for #1 - Intercepts filenames on HtmlReporter to truncate if length > 255 #2

Merged
merged 2 commits into from
Sep 14, 2016

Conversation

mAiNiNfEcTiOn
Copy link

What does this PR do:

Basically adds an 'interceptor' that verifies if the filepath being written is within 255 chars long. If not, will get the difference and remove the number of characters == difference from the baseName of the file.

Fixes #1

Where should the reviewer start:

…ritten is within 255 chars long. If not, will get the difference and remove the number of characters == difference from the baseName of the file
@mAiNiNfEcTiOn mAiNiNfEcTiOn changed the title Basically adds an 'interceptor' that verifies if the filepath being w… Fix for #1 - Intercepts files on HtmlReporter to truncate if length > 255 Sep 14, 2016
@mAiNiNfEcTiOn mAiNiNfEcTiOn changed the title Fix for #1 - Intercepts files on HtmlReporter to truncate if length > 255 Fix for #1 - Intercepts filenames on HtmlReporter to truncate if length > 255 Sep 14, 2016
fileWriter.writeFile = function writeFile(file, callback) {
if (file.length > 255) {
var excess = file.length - 255;
var baseName = path.basename(file, '.html')
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure but does fileWriter write more than just html files?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it also writes the base.css files from the report, png's etc (see screenshot below):

screen shot 2016-09-14 at 17 36 32

Copy link
Author

Choose a reason for hiding this comment

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

But those normally don't hit the 255 chars length, but I can also use the path.extname().

Will do.

@samccone
Copy link
Owner

thx for the PR, comments left on the diff.

@mAiNiNfEcTiOn
Copy link
Author

Thanks for the comments. Do you see any more places where I can improve it?

@mAiNiNfEcTiOn
Copy link
Author

mAiNiNfEcTiOn commented Sep 14, 2016

Also for a little bit more info:

Before improvements:

node gen_report.js ~/ctnl.coverage 2.60s user 0.30s system 101% cpu 2.860 total

After improvements:

node gen_report.js ~/ctnl.coverage 2.38s user 0.29s system 102% cpu 2.615 total

I guess it's always good to know :)

@samccone
Copy link
Owner

Looks great now much simpler :)

thanks a ton @mAiNiNfEcTiOn 👏

@samccone samccone merged commit 7d4f93d into samccone:master Sep 14, 2016
@mAiNiNfEcTiOn mAiNiNfEcTiOn deleted the fix-long-names branch September 14, 2016 16:46
@mAiNiNfEcTiOn
Copy link
Author

My pleasure ;)

@samccone
Copy link
Owner

Looks like #3 started happening due to this :)


fileWriter.writeFile = function writeFile(file, callback) {
var ext = path.extname(file);
file = file.slice(0, 255 - ext.length) + ext;
Copy link
Owner

Choose a reason for hiding this comment

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

this + ext should only happen if the length was > 255
see #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants