Skip to content

Commit

Permalink
fix(list-different): removed the message at the end of execution (#288)
Browse files Browse the repository at this point in the history
Co-authored-by: Dor Serero <dorserer@amazon.com>
Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
3 people committed Aug 25, 2022
1 parent d8fc957 commit 4093cb7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 39 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Expand Up @@ -269,6 +269,16 @@
"test",
"tool"
]
},
{
"login": "dorser",
"name": "dorser",
"avatar_url": "https://avatars2.githubusercontent.com/u/20969462?v=4",
"profile": "https://github.com/dorser",
"contributions": [
"code",
"maintenance"
]
}
],
"repoType": "github",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/lovely-rings-cry.md
@@ -0,0 +1,5 @@
---
"prettier-eslint-cli": patch
---

fix(list-different): removed the message at the end of execution
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -282,6 +282,7 @@ Thanks goes to these people ([emoji key][emojis]):
<td align="center"><a href="https://github.com/gwhitney"><img src="https://avatars.githubusercontent.com/u/3825429?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Glen Whitney</b></sub></a><br /><a href="#maintenance-gwhitney" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://campcode.dev/"><img src="https://avatars.githubusercontent.com/u/10620169?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rebecca Vest</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=idahogurl" title="Code">💻</a></td>
<td align="center"><a href="https://www.1stg.me/"><img src="https://avatars.githubusercontent.com/u/8336744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JounQin</b></sub></a><br /><a href="#question-JounQin" title="Answering Questions">💬</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Code">💻</a> <a href="#design-JounQin" title="Design">🎨</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Documentation">📖</a> <a href="#ideas-JounQin" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JounQin" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JounQin" title="Maintenance">🚧</a> <a href="#plugin-JounQin" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-JounQin" title="Project Management">📆</a> <a href="https://github.com/prettier/prettier-eslint-cli/pulls?q=is%3Apr+reviewed-by%3AJounQin" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Tests">⚠️</a> <a href="#tool-JounQin" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/dorser"><img src="https://avatars2.githubusercontent.com/u/20969462?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dorser</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=dorser" title="Code">💻</a> <a href="#maintenance-dorser" title="Maintenance">🚧</a></td>
</tr>
</table>

Expand Down
58 changes: 30 additions & 28 deletions src/format-files.js
Expand Up @@ -162,39 +162,41 @@ function formatFilesFromGlobs({
}

function onComplete() {
const isNotSilent = logger.getLevel() !== logger.levels.SILENT;
const isSilent = logger.getLevel() === logger.levels.SILENT || cliOptions.listDifferent;

/* use console.error directly here because
* - we don't want these messages prefixed
* - we want them to go to stderr, not stdout
*/
if (successes.length && isNotSilent) {
console.error(
messages.success({
success: chalk.green('success'),
count: successes.length,
countString: chalk.bold(successes.length)
})
);
}
if (failures.length && isNotSilent) {
process.exitCode = 1;
console.error(
messages.failure({
failure: chalk.red('failure'),
count: failures.length,
countString: chalk.bold(failures.length)
})
);
}
if (unchanged.length && isNotSilent) {
console.error(
messages.unchanged({
unchanged: chalk.gray('unchanged'),
count: unchanged.length,
countString: chalk.bold(unchanged.length)
})
);
if (!isSilent) {
if (successes.length) {
console.error(
messages.success({
success: chalk.green('success'),
count: successes.length,
countString: chalk.bold(successes.length)
})
);
}
if (failures.length) {
process.exitCode = 1;
console.error(
messages.failure({
failure: chalk.red('failure'),
count: failures.length,
countString: chalk.bold(failures.length)
})
);
}
if (unchanged.length) {
console.error(
messages.unchanged({
unchanged: chalk.gray('unchanged'),
count: unchanged.length,
countString: chalk.bold(unchanged.length)
})
);
}
}
resolve({ successes, failures });
}
Expand Down
6 changes: 0 additions & 6 deletions src/format-files.test.js
Expand Up @@ -275,12 +275,6 @@ describe('listDifferent', () => {
expect(fsMock.readFile).toHaveBeenCalledTimes(7);
expect(fsMock.writeFile).toHaveBeenCalledTimes(0);

const unchangedOutput = expect.stringMatching(/3.*files were.*unchanged/);
const successOutput = expect.stringMatching(/success.*4.*files/);
expect(console.error).toHaveBeenCalledTimes(2);
expect(console.error).toHaveBeenCalledWith(unchangedOutput);
expect(console.error).toHaveBeenCalledWith(successOutput);

const path =
'/Users/fredFlintstone/Developer/top-secret/footless-carriage/';
expect(console.log).toHaveBeenCalledTimes(4);
Expand Down
6 changes: 1 addition & 5 deletions test/tests/__snapshots__/cli.spec.js.snap
Expand Up @@ -17,10 +17,6 @@ Object {
`;

exports[`prettier-eslint test/fixtures/example*.js --write --no-eslint-ignore --no-prettier-ignore: stdout: prettier-eslint test/fixtures/example*.js --write --no-eslint-ignore --no-prettier-ignore 1`] = `
"can't resolve reference #/definitions/directiveConfigSchema from id #
can't resolve reference #/definitions/directiveConfigSchema from id #
can't resolve reference #/definitions/directiveConfigSchema from id #
can't resolve reference #/definitions/directiveConfigSchema from id #
success formatting 2 files with prettier-eslint
"success formatting 2 files with prettier-eslint
"
`;

0 comments on commit 4093cb7

Please sign in to comment.