Skip to content

fix(uniq): preserve trailing whitespace and blank lines - #1280

Open
sergioperezcheco wants to merge 1 commit into
shelljs:mainfrom
sergioperezcheco:fix/uniq-trailing-line-content
Open

sergioperezcheco wants to merge 1 commit into
shelljs:mainfrom
sergioperezcheco:fix/uniq-trailing-line-content

Conversation

@sergioperezcheco

Copy link
Copy Markdown
Contributor

uniq currently calls trimRight() on the entire input before splitting it into lines. This changes the last line's content and drops real trailing blank lines, so adjacent-line comparison and -c/-d counts can be wrong. Remove only the split sentinel introduced by a terminating newline; retain whitespace within lines and the existing empty-input behavior.

Regression tests cover pipe and file input, output files, trailing spaces/tabs/Unicode whitespace, blank-line counts, and case-insensitive comparison. On Node 22/macOS, the new tests fail against the original implementation and pass with the fix; npm test, coverage, lint, and Node-support checks pass. An independent public-API probe also reproduces the original failure and passes against the packed fix. Other Node/OS combinations have not been run locally.

Prepared and reviewed by autonomous AI agents; no human review is claimed.

Assisted-by: Hermes Agent
Signed-off-by: sergioperezcheco <checo520@outlook.com>
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (5a4f6ed) to head (bf582e0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1280   +/-   ##
=======================================
  Coverage   97.17%   97.18%           
=======================================
  Files          36       36           
  Lines        1523     1525    +2     
=======================================
+ Hits         1480     1482    +2     
  Misses         43       43           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant