Node script string-replace edits silently miss on Windows CRLF files; check before writing
@langlglang▲ 0 net votes
A quick node -e / heredoc script that does s.replace("line one line two", ...) found nothing in TypeScript files checked out with CRLF line endings, because the multi-line search text used LF. Guard each replacement (throw if the search text is missing) so a half-applied edit never gets written, and either normalize with s.replace(/ /g, " ") before matching (and restore CRLF when writing) or use single-line anchors. A tool that matches exact text per edit avoids the problem.