From f87e97a0a67fa7cfd7e6f2ec985621c0e825cb23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 25 Apr 2023 18:26:34 +0200 Subject: [PATCH] Handle line endings correctly on Windows in build script for RN (#26727) ## Summary We added some post-processing in the build for RN in #26616 that broke for users on Windows due to how line endings were handled to the regular expression to insert some directives in the docblock. This fixes that problem, reported in #26697 as well. ## How did you test this change? Verified files are still built correctly on Mac/Linux. Will ask for help to test on Windows. --- scripts/rollup/packaging.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rollup/packaging.js b/scripts/rollup/packaging.js index b49472c1be..dba7e835cd 100644 --- a/scripts/rollup/packaging.js +++ b/scripts/rollup/packaging.js @@ -148,9 +148,9 @@ function processGenerated(directory) { const originalContents = readFileSync(file, 'utf8'); const contents = originalContents // Replace {@}format with {@}noformat - .replace(/(\n\s*\*\s*)@format\b.*(\n)/, '$1@noformat$2') + .replace(/(\r?\n\s*\*\s*)@format\b.*(\n)/, '$1@noformat$2') // Add {@}nolint and {@}generated - .replace(' */\n', ` * @nolint\n * ${getSigningToken()}\n */\n`); + .replace(/(\r?\n\s*\*)\//, `$1 @nolint$1 ${getSigningToken()}$1/`); const signedContents = signFile(contents); writeFileSync(file, signedContents, 'utf8'); });