Also split on unicode line and paragraph separators

This commit is contained in:
Sander Declerck 2025-08-06 15:28:39 +02:00
parent df8bb9be74
commit fe39b9cc23
No known key found for this signature in database

View file

@ -28,7 +28,7 @@ export function removeLinesMatchingPattern(filePath, pattern) {
} }
const fileContent = fs.readFileSync(filePath, "utf-8"); const fileContent = fs.readFileSync(filePath, "utf-8");
const lines = fileContent.split(/[\r\n]+/); const lines = fileContent.split(/[\r\n\u2028\u2029]+/);
const updatedLines = lines.filter((line) => !shouldRemoveLine(line, pattern)); const updatedLines = lines.filter((line) => !shouldRemoveLine(line, pattern));
fs.writeFileSync(filePath, updatedLines.join(os.EOL), "utf-8"); fs.writeFileSync(filePath, updatedLines.join(os.EOL), "utf-8");
} }