Closed bcoe closed 9 years ago
@bcoe Need to rebase and drop commit 4181246 from this branch, I think. :ok_hand:
@nexdrew I purposefully forked off of the code-coverage branch, my plan was to add a few more tests to this refactor to get coverage up a bit.
Ok, sorry. Ignore me.
@dthree Can you review too?
@sindresorhus yes :)
This is looking :+1: to me at this point.
@dthree @sindresorhus if you felt like giving me commit access, I'd be happy to land a few more tests on this branch before merging -- I'd like to get coverage a bit closer to 100%, and test all the weird edge-cases of wrapping.
@sindresorhus I'm going to merge this to start.
Wouldn't mind giving him access to this repo if you're fine with that, he's put a ton of work into it.
Done! Was planning to do so after this PR anyways. Really appriciate the work you've done on this @bcoe :)
Looks good to me too.
Landed! :)
Haha :) Thanks for all your work @bcoe
In this pull request I've added support for the concept of
hard
vs.soft
wrapping:soft
wrapping allows words that take up more thancols
to be printed on a single line.hard
wrapping does not allow a row to ever contain more thancols
characters.This functionality is modeled after @substack's node-wordwrap.
In this pull I've also added code coverage support, which helps me ensure that I'm not being lazy while writing tests.
How I Tested
cliui
andyargs
, and my goal was to makeansi-wordwrap
a drop in replacement. Here's the script I wrote:I used this script to compare both
soft
andhard
wrapping between the two modules, and managed to get the output pretty close to parity (I actually think that I found a few bugs in wordwrap, that are not present in ansi-wrap related to wrapping close to column boundaries) \o/npm link
,wrap-ansi
and use it as a drop in replacement forwordwrap
. Both theyargs
andcliui
codebases run with the replacement.reviewers: @dthre, @sindresorhus, @phated, @nexdrew
note: I started out by trying to tack this functionality onto the existing algorithm, but it turned out to be a hard enough problem that refactoring the algorithm seemed like the better approach.