Skip to content

Commit

Permalink
Do not comment if file is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed Nov 30, 2023
1 parent b4eda1a commit 60f042d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9563,6 +9563,11 @@ async function run() {
let content = message;
if (!message && filePath) {
content = fs_1.default.readFileSync(filePath, 'utf8');
// exit if file is empty (and do not comment)
if (content.length === 0) {
core.info('File is empty. Exiting.');
return;
}
if (mdLanguage) {
content = `\`\`\`${mdLanguage}\n${content}\n\`\`\``;
}
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ async function run() {
let content: string = message;
if (!message && filePath) {
content = fs.readFileSync(filePath, 'utf8');

// exit if file is empty (and do not comment)
if (content.length === 0) {
core.info('File is empty. Exiting.');
return;
}

if (mdLanguage) {
content = `\`\`\`${mdLanguage}\n${content}\n\`\`\``;
}
Expand Down

0 comments on commit 60f042d

Please sign in to comment.