From d30698cb38793758c96fabedfed7864c9c98dad0 Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Fri, 8 Nov 2024 16:00:23 +0100 Subject: [PATCH] ci(pull-request): Fix generate comments for empty changes (#2593) --- comment-markup.md | 0 scripts/generateChangedIconsCommentMarkup.mjs | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 comment-markup.md diff --git a/comment-markup.md b/comment-markup.md new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/generateChangedIconsCommentMarkup.mjs b/scripts/generateChangedIconsCommentMarkup.mjs index 8d32dae94..8b69fceff 100644 --- a/scripts/generateChangedIconsCommentMarkup.mjs +++ b/scripts/generateChangedIconsCommentMarkup.mjs @@ -15,11 +15,21 @@ const BASE_URL = 'https://lucide.dev/api/gh-icon'; const changedFilesPathString = process.env.CHANGED_FILES; +if (changedFilesPathString == null) { + console.error('CHANGED_FILES env variable is not set'); + process.exit(1); +} + const changedFiles = changedFilesPathString .split(' ') .map((file) => file.replace('.json', '.svg')) .filter((file, idx, arr) => arr.indexOf(file) === idx); +if (changedFiles.length === 0) { + console.log('No changed icons found'); + process.exit(0); +} + const getImageTagsByFiles = (files, getBaseUrl, width) => files.map((file) => { const svgContent = fs.readFileSync(path.join(process.cwd(), file), 'utf-8');