Back to Explore

sindresorhus/cli-truncate

GitHub
3 updates · last 90 days1 watchersOpen source

Last release:

cli-truncate truncates a string to a specified width in the terminal, with options to choose the truncation position (start, middle, or end). It handles ANSI escape codes, Unicode surrogate pairs, and fullwidth characters, making it useful for safely displaying styled or wide text without overflowing terminal columns.

Project status

  • Actively maintained, with recent GitHub updates in 2026 (latest noted update: v6.1.1 on 2026-07-09).
  • Update cadence appears steady, with multiple tagged updates in 2026, including June to July gaps of about 1 to 3 weeks between v6.0.1, v6.1.0, and v6.1.1.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v6.1.1

    v6.1.1 contains a small fix to how `preferTruncationOnSpace` accounts for the rendered width of `truncationCharacter` when choosing a truncation point. This is intended to keep the final output within the requested terminal column width, especially when the truncation character is wider than one column.

  • v6.1.0

    v6.1.0 focuses on stricter input validation for cli-truncate. The release notes only mention “Improve input validation”, while the code adds specific runtime checks and new TypeError cases for invalid arguments.

  • v6.0.1

    Release v6.0.1 contains a targeted fix for the `position: 'middle'` behavior to ensure the rendered output stays within the requested terminal column budget. The change primarily affects the `space: true` path (middle truncation with padded truncation characters) and adds tests for small column widths.

  • v6.0.0

    v6.0.0 primarily raises the minimum supported Node.js version to 22. The diff also includes dependency updates (notably a major bump of slice-ansi) and some CI workflow changes, but the release notes only document the Node requirement.

    Breaking
  • v5.2.0

    v5.2.0 only updates project dependencies, with no source code changes shown in the diff. The package version is bumped, and dependency version ranges in package.json are modified.

  • v5.1.1

    Release v5.1.1 is a small patch release. It adjusts the logic for the columns=1 case so that when the input already fits, the original text is returned instead of always returning the truncation character.

  • v5.1.0

    cli-truncate v5.1.0 changes how the truncation character (ellipsis) is rendered when the input string contains ANSI styled text. For `position: 'start'` and `position: 'end'`, the truncation character now inherits the active ANSI style at the truncation boundary, instead of breaking the style around the ellipsis.

  • v5.0.0

    v5.0.0 primarily updates the supported Node.js runtime to Node 20 and bumps project dependencies. The functional change that appears to matter most is a different truncation result for surrogate-pair characters, which is not called out in the release notes.

    Breaking
  • v4.0.0

    This release primarily updates the package to require Node.js 18 and modernizes the build/test tooling. While the release notes only mention the runtime requirement, the code diff also includes changes to the truncation algorithm edge cases, TypeScript type exports, and a major dependency bump that can alter rendered width calculations.

    Breaking
  • v3.1.0

    v3.1.0 adds a new `truncationCharacter` option that lets callers customize the character (or string) used at the truncation break point. The default remains the ellipsis character (`…`). The change is reflected in TypeScript types, README documentation, and new test coverage for multiple positions and edge cases.

    Features