Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dzencot committed Jul 3, 2024
1 parent 383741a commit 1468490
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ program
.option('-r, --rules "rule1, rule2, ..."', 'languagetools rules', '')
.option('-l, --language <Ru-ru>', 'A language code like en-US, de-DE, fr, or auto to guess the language automatically', 'auto')
.option('-f, --file <wrong_words.txt>', 'Destination', '/content/wrong_words.txt')
.option('-i, --ignore <file_path>', 'Path to file with ignore contexts', '/content/ignore')
.action((dirPath = '/content', filePath, options) => {
exec(serverStartCommand, () => setTimeout(async () => {
const rules = options.rules.split(',').map((item) => item.trim()).filter((item) => item);
const language = options.language;
const ignorePath = options.ignore;

const errors = await getErrors(dirPath, language, rules);
writeIgnoreErrorsFile(errors, filePath);
const filtered = filterIgnoredErrors(errors, ignorePath);

writeIgnoreErrorsFile(filtered, filePath);
}, 5000));
});

Expand Down
2 changes: 2 additions & 0 deletions ignore_dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@ javascript
hexlet
linter
тернарника
авторизируют
гитхабе
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const formatError = (error, isColored) => {
} = error;

const fileLineMessage = formatMessage(getLineError(error), isColored && 'blue');
const contextMessage = formatContextMessage(match.context.text, match.context.offset, match.context.length);
const contextMessage = formatContextMessage(match.context.text, match.context.offset, match.context.length, isColored);

const errorMessage = formatMessage(match.message, isColored && 'red');

Expand Down Expand Up @@ -249,7 +249,7 @@ const writeIgnoreErrorsFile = (errors, ignoreFilePath) => {
const formatedErrors = formatErrors(errors);
const result = formatedErrors.join(errorDelimeter);

fs.writeFileSync(ignoreFilePath, result, 'utf-8');
fs.appendFile(`${ignoreFilePath}${errorDelimeter}`, result, 'utf-8');
};

export {
Expand Down

0 comments on commit 1468490

Please sign in to comment.