From 3c39f469690abe4131b53366546c13e7627a1e51 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 20 Dec 2023 16:01:43 +0100 Subject: [PATCH] scripts/check-docs-quality: only check listed files if files are listed Signed-off-by: Patrik Oldsberg --- scripts/check-docs-quality.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/check-docs-quality.js b/scripts/check-docs-quality.js index 2890f1cf33..d3b51a49a3 100755 --- a/scripts/check-docs-quality.js +++ b/scripts/check-docs-quality.js @@ -14,7 +14,11 @@ * limitations under the License. */ const { spawnSync } = require('child_process'); -const { resolve: resolvePath, join: joinPath } = require('path'); +const { + resolve: resolvePath, + join: joinPath, + relative: relativePath, +} = require('path'); const fs = require('fs').promises; const IGNORED = [ @@ -94,9 +98,9 @@ async function runVale(files) { } async function main() { - const files = await listFiles(); - if (process.argv.includes('--ci-args')) { + const files = await listFiles(); + process.stdout.write( // Workaround for not being able to pass arguments to the vale action JSON.stringify([...files]), @@ -106,7 +110,14 @@ async function main() { await exitIfMissingVale(); - const success = await runVale(files); + const absolutePaths = process.argv + .slice(2) + .filter(path => !path.startsWith('-')); + const relativePaths = absolutePaths.map(path => relativePath(rootDir, path)); + + const success = await runVale( + relativePaths.length === 0 ? await listFiles() : relativePaths, + ); if (!success) { process.exit(2); }