Skip to content

Fix files from absolute path to close #726 and add RR_VOID_PIPE env var. - #730

Merged
mathiasrw merged 1 commit into
mainfrom
fix/726
Oct 13, 2026
Merged

mathiasrw merged 1 commit into
mainfrom
fix/726

Conversation

@mathiasrw

Copy link
Copy Markdown
Owner

Closes #726. Also has the warning from #719 (already closed) and a new env. var to ignore piped data.

A file given with an absolute path is now changed (#726)

The working directory was put in front of the path, also when the path was absolute, so the file could not be renamed to its backup and was not changed.

  • src/engine.ts now uses path.resolve() in the two places that used path.join() with the working directory: the path of the backup, and the file / dirpath variables of --replacement-js.
  • For a relative path the result is the same as before.
  • In --replacement-js, file_rel and dirpath_rel change for an absolute path outside the working directory (like ../../tmp/notes/a.md and not tmp/notes/a.md).

RR_VOID_PIPE

Set the env. var RR_VOID_PIPE (to anything but an empty string) to ignore piped data in every call. It is --void-pipe without adding the flag to each command.

> RR_VOID_PIPE=1 rexreplace 'foo' 'bar' myfile.md
  • --replacement-pipe and --trim-pipe need piped data, so they give a warning when the env. var is set.

Warnings (#719)

A third kind of message next to info and errors: warn() in src/output.ts.

  • A warning starts with 🟡 and goes to stderr. --quiet and --quiet-total hide it. It never stops the run, also not with --halt.
  • It is given when data is piped in together with files and no flag uses the data. Empty piped data, or only a line break, gives no warning.
> printf x | rexreplace o x my.file
 🟡 Data is piped in, but no flag tells what to do with it. It is not used.

my.file

This replaces the line Piped data never used. that was only shown with --verbose.

Other changes to the output

  • There is now an empty line under each warning and each ❌ error.
  • --replacement-pipe without piped data no longer prints the help text. It stops with ❌ No data piped into replacement.

Version

  • The version is 8.0.0-dev. The version checks in test/cli/global.run.node.sh now also take a version that ends on dev.

Tests

  • test/js/fix/726.test.js and test/js/fix/719.test.js are new, and test/cli/run.sh has new asserts for RR_VOID_PIPE and the warning.
  • test/js/fix/691.test.js, test/js/fix/700.test.js and test/js/verbose.test.js are changed for the new output.

Good to know

🤖 Generated with Claude Code

@mathiasrw mathiasrw changed the title Fix files given with an absolute path, add RR_VOID_PIPE and warnings to close #726 Fix files from absolute path to close #726 and add RR_VOID_PIPE env var. Oct 13, 2026
@mathiasrw
mathiasrw merged commit 29b8088 into main Oct 13, 2026
7 checks passed
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.

A file given with an absolute path is not changed

1 participant