-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Code refactoring #58
Code refactoring #58
Conversation
Why are the tests not relevant anymore? |
Would be nice to have tests for this. |
Reduce two lines into one Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Those tests were expecting results that do not accord with the fact that the boxes shouldn't overflow the terminal. I found that by investigating those and try running them in a separate script. I observed that the test produced a box exceeding the terminal's size and accounting it as Ok, while accounting the new version (The one that doesn't overflow anymore) as Ko. |
This is a very good idea, I'll get to it. |
Changes done, waiting for your review 👍 |
Wouldn't it be better to adjust the tests instead of removing them? |
Changes done, waiting for your review
I can do it. Tho the it is now equivalent as combining the 'align option' tests with the new 'overflow' test. If anything, one one these two would already Ko before. I'll push it in the next minutes. |
Readapted the tests. I pushed the changes. 👌 |
b053859
to
c3c1335
Compare
Looks good now. Thanks :) |
This PR has for objective to provide a little code refactoring in order to make the library more easily maintainable/scalable/readable.
Effectively the main function of the library was around 150 lines long and it renders it really hard to read/understand.
So I decided to divide it a little, now the code is separated into two 'main functions' :
This new function takes in 4 arguments:
This allows for more flexibility regarding the width of the content. It'll allow an easy implementation for issue #51. (PR coming soon). Also the way this function is done/used fixes #53 and all kind of similar bugs where the box would exceed the terminal's size. See images below:
This pretty much sums up the purpose of this PR. It's kind of a preparation for other PRs I'm preparing
Fixes #53