Skip to content

Tell why a replacement file can not be read, and only once to close #818 - #835

Merged
mathiasrw merged 4 commits into
mainfrom
fix/818
Oct 23, 2026
Merged

mathiasrw merged 4 commits into
mainfrom
fix/818

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #818

Stacked on #834.

Change

  • A replacement file that can not be read now tells the reason, and shows the path as JSON, so a line break or a space at the end can be seen:
 ❌ The replacement file can not be read: "nope.txt" (ENOENT)
 ❌ The replacement file can not be read: "adir" (EISDIR)
 ❌ The replacement file can not be read: "footer.html\n" (ENOENT)

The last one is a path piped in with echo and -R, without -T. Before, all three said the same, and the last one showed a blank line.

  • With --js a path that can not be read is now an error once in the run. Before it was once for each file, and in status.errors as many times.

Tests

test/fix/818.test.js is new. Two tests of --replacement-file have the new message. yarn test-ci passes.

From the review of 23 October.

After the review of 24 October

  • The reason is now the text of the error, like nope.txt (ENOENT: no such file or directory), and not only the code.
  • The path is shown as it is, so a Windows path like my\dir/nope.txt can be pasted back. Only a path that starts or ends with a space, or has a control char like the line break from echo, is shown as JSON, so that char can be seen: "nope.txt\n" (ENOENT: …).

After the review of 24 October

Closes #847

  • The bare call at the end of the reason goes too, so EISDIR is (EISDIR: illegal operation on a directory), without , read.
  • A path with a char that can not be seen is shown as JSON with that char as \u, like "no\u200bpe.txt": the C1 range, the zero-width chars, the line and paragraph separators and the marks for the direction of text. Before, only ASCII control chars and a space at the start or end were shown, so a zero-width space looked like a normal path.

Follow-up

  • The regexes are made once, in re: re.unclearPath finds a space at the start or the end and the chars that can not be seen in one test, re.invisibleChars escapes the ones JSON leaves as they are, and re.fileCallInMessage is the end of the message that is told already.
  • unreadable() is now pathAndReason(), with a plain if in place of the nested ternary. The output is the same.

@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 13:05
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 13:21
@mathiasrw
mathiasrw added this pull request to stack #841 October 23, 2026 13:56
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 14:14
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 14:24
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 15:20
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 15:23
@mathiasrw
mathiasrw removed this pull request from stack #841 October 23, 2026 15:57
@mathiasrw
mathiasrw added this pull request to stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw removed this pull request from stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw added this pull request to stack #850 October 23, 2026 16:17
@mathiasrw
mathiasrw removed this pull request from stack #850 October 23, 2026 16:47
@mathiasrw
mathiasrw added this pull request to stack #853 October 23, 2026 16:51
@mathiasrw
mathiasrw force-pushed the fix/818 branch 2 times, most recently from 2c1e121 to 510e6db Compare October 23, 2026 17:00
Base automatically changed from fix/817 to main October 23, 2026 17:01
@mathiasrw
mathiasrw merged commit 5116c10 into main Oct 23, 2026
6 of 7 checks passed
@mathiasrw
mathiasrw deleted the fix/818 branch October 23, 2026 17:12
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.

Fix small things in the message when a replacement file can not be read Fix --replacement-file errors that hide the reason

1 participant