Skip to content

Commit

Permalink
Add check if file exists before linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-mairose-sp committed Aug 11, 2022
1 parent c86267f commit 4a2b9bc
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/read_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ const readFilesToAnalyze = async (githubWorkspace, fileGlob) => {
let fileContents = [];
for (let i = 0, len = files.length; i < len; i++) {
console.log(`FILE ${i} ${files[i]}`);
fileContents.push({
file: files[i],
content: fs.readFileSync(files[i], 'utf-8')
});
try {
if (fs.existsSync(files[i])) {
//file exists
console.log("File Exists, adding it to be linted")
fileContents.push({
file: files[i],
content: fs.readFileSync(files[i], 'utf-8')
});
} else {
console.log("File does not exist, if the file was intentially deleted during the PR ignore this comment")
}
} catch(err) {
console.error(err)
}
}

return fileContents;
Expand Down

0 comments on commit 4a2b9bc

Please sign in to comment.