mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Tools: Improve error message and suggested command when checkIgnoredFiles pre-commit hook fails
This commit is contained in:
parent
0d5bca20d3
commit
afedc53354
@ -1,9 +1,11 @@
|
||||
import { execCommand, getRootDir } from '@joplin/utils';
|
||||
import { toSystemSlashes } from '@joplin/utils/path';
|
||||
import { readFile, writeFile } from 'fs-extra';
|
||||
import { chdir } from 'process';
|
||||
|
||||
const main = async () => {
|
||||
chdir(await getRootDir());
|
||||
const rootDir = await getRootDir();
|
||||
chdir(rootDir);
|
||||
|
||||
const previousContent = {
|
||||
'.gitignore': await readFile('.gitignore', 'utf8'),
|
||||
@ -20,7 +22,7 @@ const main = async () => {
|
||||
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 updateIgnored`');
|
||||
throw new Error(`.gitignore or .eslintignore would be modified - run \`cd "${toSystemSlashes(rootDir)}" && yarn updateIgnored\``);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user