Skip to content

Commit

Permalink
feat(cli): check if '.cache' is git ignored in compas check-env
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Jun 1, 2023
1 parent 94a10c4 commit 70573d7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/cli/src/compas/commands/check-env.js
Expand Up @@ -48,6 +48,7 @@ Versions:
await Promise.all([
areOtherCompasVersionsInstalled(compasVersion),
isEnvLocalNotIgnored(),
isDotCacheNotIgnored(),
isDockerInstalled(),
isGraphvizInstalled(),
])
Expand Down Expand Up @@ -94,6 +95,30 @@ async function isEnvLocalNotIgnored() {
};
}

/**
* Checks if the `.cache` folder is ignored.
*
* @returns {Promise<{ failed: boolean, message?: string }>}
*/
async function isDotCacheNotIgnored() {
const { exitCode } = await exec(`git check-ignore -q .cache`);

// 128 if no git repo exists in directory
const result = exitCode !== 0 && exitCode !== 128;

if (!result) {
return {
failed: false,
};
}

return {
failed: true,
message:
"X '.cache' is not git ignored. Please add it to your '.gitignore'. This directory is used to cache results for tools like Prettier and ESLint.",
};
}

/**
* Multiple versions of compas conflict with the use of ES Module live bindings, which
* leads to weird behaviour. So warn if that is happening.
Expand Down

0 comments on commit 70573d7

Please sign in to comment.