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:
parent
cc4e69bf92
commit
1d709a3b5c
@ -863,6 +863,7 @@ packages/tools/buildServerDocker.js
|
||||
packages/tools/buildServerDocker.test.js
|
||||
packages/tools/bundleDefaultPlugins.js
|
||||
packages/tools/bundleDefaultPlugins.test.js
|
||||
packages/tools/checkIgnoredFiles.js
|
||||
packages/tools/checkLibPaths.js
|
||||
packages/tools/checkLibPaths.test.js
|
||||
packages/tools/convertThemesToCss.js
|
||||
|
18
.github/scripts/run_ci.sh
vendored
18
.github/scripts/run_ci.sh
vendored
@ -153,6 +153,24 @@ if [ "$IS_PULL_REQUEST" == "1" ] || [ "$IS_DEV_BRANCH" = "1" ]; then
|
||||
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
|
||||
# building PRs so we disable it in this case. The Linux build should provide
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -848,6 +848,7 @@ packages/tools/buildServerDocker.js
|
||||
packages/tools/buildServerDocker.test.js
|
||||
packages/tools/bundleDefaultPlugins.js
|
||||
packages/tools/bundleDefaultPlugins.test.js
|
||||
packages/tools/checkIgnoredFiles.js
|
||||
packages/tools/checkLibPaths.js
|
||||
packages/tools/checkLibPaths.test.js
|
||||
packages/tools/convertThemesToCss.js
|
||||
|
@ -13,5 +13,6 @@ module.exports = {
|
||||
'*.{js,jsx,ts,tsx}': [
|
||||
'yarn run linter-precommit',
|
||||
'yarn run checkLibPaths',
|
||||
'node packages/tools/checkIgnoredFiles.js',
|
||||
],
|
||||
};
|
||||
|
33
packages/tools/checkIgnoredFiles.ts
Normal file
33
packages/tools/checkIgnoredFiles.ts
Normal 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);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user