Incremental migration
Move from string-width, wrap-ansi, strip-ansi and slice-ansi one import at a time, or move a transitive copy with npm overrides, checking each step.
Each drop-in is graded on its own, so a program can move one import at a time and ship in between. Nothing about moving one path depends on the others.
One import at a time
- import stringWidth from 'string-width';
+ import stringWidth from 'linegauge';
- import wrapAnsi from 'wrap-ansi';
+ import wrapAnsi from 'linegauge/wrap';
- import stripAnsi from 'strip-ansi';
+ import stripAnsi from 'linegauge/strip';
- import sliceAnsi from 'slice-ansi';
+ import sliceAnsi from 'linegauge/slice';Or let the codemod do it: npx burgee migrate --dry-run lists every import it would rewrite —
only drop-ins graded level with their incumbent — and npx burgee migrate rewrites them
(Migrate).
A copy you do not import yourself
string-width sits under most of the terminal ecosystem, so your tree probably carries copies
your code never imports. The root default export is call-compatible with string-width's, so an
overrides entry moves those too, without a code change:
{ "overrides": { "string-width": "npm:linegauge@^0.5" } }Only string-width can be moved this way. The other three are subpaths, and an override
replaces a whole package, so wrap-ansi pointed at linegauge would resolve to width.
Checking each step
Once the imports have moved, the dependencies can go:
npm uninstall string-width wrap-ansi strip-ansi slice-ansi
npm ls string-widthnpm ls shows whatever still pulls a copy in transitively; that is what the override above is
for. The behaviour each step keeps is the incumbent's own suite's, as
Compatibility shows — to the case, not to a description.
Wrapping help text
Wrap a paragraph to the terminal's width with an indent, and to a fixed width in a pipe or a test, so help output never runs off the right edge.
linegauge
Every export of linegauge, with its signature and doc comment: lineCount, measure, width, width, strip, truncate and 3 more, plus 4 types.