Skip to content

Commit

Permalink
Only check for gitattributes and gitignore if directory is a git …
Browse files Browse the repository at this point in the history
…repo (closes #9)
  • Loading branch information
knutkirkhorn committed Apr 2, 2023
1 parent 908c0fe commit 05b9efb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ async function fileExists(filePath) {
}

const defaultFilesToCheck = [
'.editorconfig',
'.gitattributes'
'.editorconfig'
];

async function isGitRepo(directoryPath) {
Expand All @@ -53,6 +52,9 @@ async function checkDirectoryFiles(directoryPath) {
const isJavascriptDirectory = await hasPackageJson(directoryPath);
if (isJavascriptDirectory) filesToCheck.push('.eslintrc.json');

const isDirectoryGitRepo = await isGitRepo(directoryPath);
if (isDirectoryGitRepo) filesToCheck.push('.gitignore', '.gitattributes');

for (const fileToCheck of filesToCheck) {
const filePath = path.join(directoryPath, fileToCheck);
const currentFileExists = await fileExists(filePath);
Expand Down

0 comments on commit 05b9efb

Please sign in to comment.