From 5296643de8f7f4be38ef51c65ac321dafac026ae Mon Sep 17 00:00:00 2001 From: Dunqing Date: Wed, 11 Dec 2024 00:13:45 +0800 Subject: [PATCH] chore(tasks/transform-conformance): update only when the output differs from the original output --- tasks/transform_conformance/update_fixtures.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tasks/transform_conformance/update_fixtures.js b/tasks/transform_conformance/update_fixtures.js index 9f5b9166152c1b..9253378c0ae459 100644 --- a/tasks/transform_conformance/update_fixtures.js +++ b/tasks/transform_conformance/update_fixtures.js @@ -93,8 +93,12 @@ async function updateDir(dirPath, options, hasChangedOptions) { ) { const inputPath = pathJoin(dirPath, filenames.input), outputPath = pathJoin(dirPath, filenames.output); - await backupFile(outputPath); - await transform(inputPath, outputPath, options); + const originalCode = (await readFile(outputPath)).toString(); + const code = await transform(inputPath, outputPath, options); + if (originalCode.trim() !== code.trim()) { + await backupFile(outputPath); + await writeFile(outputPath, code); + } } // Process subfolders @@ -177,7 +181,7 @@ async function transform(inputPath, outputPath, options) { } const { code } = await transformFileAsync(inputPath, options); - await writeFile(outputPath, code); + return code; } /**