1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Tools: Check for files that should have been ignored on pre-commit

This commit is contained in:
Laurent Cozic 2023-07-16 11:52:42 +01:00
parent cc4e69bf92
commit 1d709a3b5c
5 changed files with 54 additions and 0 deletions

View File

@ -863,6 +863,7 @@ packages/tools/buildServerDocker.js
packages/tools/buildServerDocker.test.js packages/tools/buildServerDocker.test.js
packages/tools/bundleDefaultPlugins.js packages/tools/bundleDefaultPlugins.js
packages/tools/bundleDefaultPlugins.test.js packages/tools/bundleDefaultPlugins.test.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.js packages/tools/checkLibPaths.js
packages/tools/checkLibPaths.test.js packages/tools/checkLibPaths.test.js
packages/tools/convertThemesToCss.js packages/tools/convertThemesToCss.js

View File

@ -153,6 +153,24 @@ if [ "$IS_PULL_REQUEST" == "1" ] || [ "$IS_DEV_BRANCH" = "1" ]; then
fi fi
fi fi
# =============================================================================
# Check .gitignore and .eslintignore files - they should be updated when
# new TypeScript files are added by running `yarn run updateIgnored`.
# See coding_style.md
# =============================================================================
if [ "$IS_PULL_REQUEST" == "1" ]; then
if [ "$IS_LINUX" == "1" ]; then
echo "Step: Checking for files that should have been ignored..."
node packages/tools/checkIgnoredFiles.js
testResult=$?
if [ $testResult -ne 0 ]; then
exit $testResult
fi
fi
fi
# ============================================================================= # =============================================================================
# Find out if we should run the build or not. Electron-builder gets stuck when # Find out if we should run the build or not. Electron-builder gets stuck when
# building PRs so we disable it in this case. The Linux build should provide # building PRs so we disable it in this case. The Linux build should provide

1
.gitignore vendored
View File

@ -848,6 +848,7 @@ packages/tools/buildServerDocker.js
packages/tools/buildServerDocker.test.js packages/tools/buildServerDocker.test.js
packages/tools/bundleDefaultPlugins.js packages/tools/bundleDefaultPlugins.js
packages/tools/bundleDefaultPlugins.test.js packages/tools/bundleDefaultPlugins.test.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.js packages/tools/checkLibPaths.js
packages/tools/checkLibPaths.test.js packages/tools/checkLibPaths.test.js
packages/tools/convertThemesToCss.js packages/tools/convertThemesToCss.js

View File

@ -13,5 +13,6 @@ module.exports = {
'*.{js,jsx,ts,tsx}': [ '*.{js,jsx,ts,tsx}': [
'yarn run linter-precommit', 'yarn run linter-precommit',
'yarn run checkLibPaths', 'yarn run checkLibPaths',
'node packages/tools/checkIgnoredFiles.js',
], ],
}; };

View File

@ -0,0 +1,33 @@
import { execCommand, getRootDir } from '@joplin/utils';
import { readFile, writeFile } from 'fs-extra';
import { chdir } from 'process';
const main = async () => {
chdir(await getRootDir());
const previousContent = {
'.gitignore': await readFile('.gitignore', 'utf8'),
'.eslintignore': await readFile('.eslintignore', 'utf8'),
};
await execCommand('yarn run updateIgnored', { quiet: true });
const newContent = {
'.gitignore': await readFile('.gitignore', 'utf8'),
'.eslintignore': await readFile('.eslintignore', 'utf8'),
};
if (newContent['.gitignore'] !== previousContent['.gitignore'] || newContent['.eslintignore'] !== previousContent['.eslintignore']) {
await writeFile('.gitignore', previousContent['.gitignore'], 'utf8');
await writeFile('.eslintignore', previousContent['.eslintignore'], 'utf8');
throw new Error('.gitignore or .eslintignore would be modified - run `yarn run updateIgnored`');
}
};
if (require.main === module) {
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
main().catch((error) => {
console.error(error);
process.exit(1);
});
}