Skip to content

Commit

Permalink
Clean up double message
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronMoat committed Jan 10, 2024
1 parent 95ecfe4 commit 80f98de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/cli/lint/internalLints/refreshIgnoreFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ describe('refreshIgnoreFiles', () => {
});

expect(`\n${stdout()}`).toBe(`
The .eslintignore file is out of date. Run pnpm exec skuba format to update it. refresh-ignore-files
The .gitignore file is out of date. Run pnpm exec skuba format to update it. refresh-ignore-files
The .eslintignore file is out of date. Run \`pnpm exec skuba format\` to update it. refresh-ignore-files
The .gitignore file is out of date. Run \`pnpm exec skuba format\` to update it. refresh-ignore-files
`);

expect(writeFile).not.toHaveBeenCalled();
Expand Down
32 changes: 15 additions & 17 deletions src/cli/lint/internalLints/refreshIgnoreFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import { inspect } from 'util';

import { writeFile } from 'fs-extra';
import stripAnsi from 'strip-ansi';

import type { Logger } from '../../../utils/logging';
import { detectPackageManager } from '../../../utils/packageManager';
Expand Down Expand Up @@ -53,9 +54,8 @@ export const refreshIgnoreFiles = async (
await writeFile(filepath, data);
return {
needsChange: false,
msg: `Refreshed ${logger.bold(filename)}. ${logger.dim(
'refresh-ignore-files',
)}`,
msg: `Refreshed ${logger.bold(filename)}.`,
filename,
};
}

Expand All @@ -66,13 +66,12 @@ export const refreshIgnoreFiles = async (
needsChange: true,
msg: `The ${logger.bold(
filename,
)} file is out of date. Run ${logger.bold(
)} file is out of date. Run \`${logger.bold(
packageManager.exec,
'skuba',
'format',
)} to update it. ${logger.dim('refresh-ignore-files')}`,
)}\` to update it.`,
filename,
annotationMessage: `The ${filename} file is out of date. Run \`${packageManager.exec} skuba format\` to update it.`,
};
}

Expand All @@ -86,7 +85,7 @@ export const refreshIgnoreFiles = async (
// Log after for reproducible test output ordering
results.forEach((result) => {
if (result.msg) {
logger.warn(result.msg);
logger.warn(result.msg, logger.dim('refresh-ignore-files'));
}
});

Expand All @@ -95,16 +94,15 @@ export const refreshIgnoreFiles = async (
return {
ok: !anyNeedChanging,
fixable: anyNeedChanging,
annotations: results.flatMap(
({ needsChange, filename, annotationMessage }) =>
needsChange && annotationMessage
? [
{
path: filename,
message: annotationMessage,
},
]
: [],
annotations: results.flatMap(({ needsChange, filename, msg }) =>
needsChange && msg
? [
{
path: filename,
message: stripAnsi(msg),
},
]
: [],
),
};
};
Expand Down

0 comments on commit 80f98de

Please sign in to comment.