2023-07-16 12:52:42 +02:00
|
|
|
import { execCommand, getRootDir } from '@joplin/utils';
|
2024-02-27 13:46:02 +02:00
|
|
|
import { toSystemSlashes } from '@joplin/utils/path';
|
2023-07-16 12:52:42 +02:00
|
|
|
import { readFile, writeFile } from 'fs-extra';
|
|
|
|
import { chdir } from 'process';
|
|
|
|
|
|
|
|
const main = async () => {
|
2024-02-27 13:46:02 +02:00
|
|
|
const rootDir = await getRootDir();
|
|
|
|
chdir(rootDir);
|
2023-07-16 12:52:42 +02:00
|
|
|
|
|
|
|
const previousContent = {
|
|
|
|
'.gitignore': await readFile('.gitignore', 'utf8'),
|
|
|
|
'.eslintignore': await readFile('.eslintignore', 'utf8'),
|
|
|
|
};
|
|
|
|
|
2024-01-26 22:19:28 +02:00
|
|
|
await execCommand('yarn updateIgnored', { quiet: true });
|
2023-07-16 12:52:42 +02:00
|
|
|
|
|
|
|
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');
|
2024-02-27 13:46:02 +02:00
|
|
|
throw new Error(`.gitignore or .eslintignore would be modified - run \`cd "${toSystemSlashes(rootDir)}" && yarn updateIgnored\``);
|
2023-07-16 12:52:42 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|