Skip to content

Commit

Permalink
Only show errors (closes #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
knutkirkhorn committed May 17, 2023
1 parent 9c3b8b8 commit 9ef1721
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,26 @@ async function checkDirectoryFiles(directoryPath) {
const isDirectoryGitRepo = await isGitRepo(directoryPath);
if (isDirectoryGitRepo) filesToCheck.push('.gitignore', '.gitattributes');

let hasPrintedCheck = false;

for (const fileToCheck of filesToCheck) {
const filePath = path.join(directoryPath, fileToCheck);
const currentFileExists = await fileExists(filePath);
const currentLogSymbol = currentFileExists
? logSymbols.success
: logSymbols.error;
console.log(`${currentLogSymbol} ${fileToCheck}`);

// eslint-disable-next-line no-continue
if (currentFileExists) continue;

if (!hasPrintedCheck) {
console.log(`\n${chalk.underline(directoryPath)}`);
hasPrintedCheck = true;
}

console.log(`${logSymbols.error} ${fileToCheck}`);
}
}

export async function checkRepoFiles(directoryPath = process.cwd()) {
const parsedDirectoryPath = path.resolve(directoryPath);
console.log(`\n${chalk.underline(parsedDirectoryPath)}`);

const {isDirectory: isPathDirectory} = await isDirectory(parsedDirectoryPath);

if (!isPathDirectory) throw new Error('Input path is not a directory');
Expand All @@ -85,7 +91,6 @@ export async function checkRepoFiles(directoryPath = process.cwd()) {
const subDirectories = await getSubDirectories(parsedDirectoryPath);

for (const subDirectory of subDirectories) {
console.log(`\n${chalk.underline(subDirectory)}`);
await checkDirectoryFiles(subDirectory);
}
}

0 comments on commit 9ef1721

Please sign in to comment.