Skip to content

Commit 4093cb7

Browse files
dorserDor SereroJounQin
authored
fix(list-different): removed the message at the end of execution (#288)
Co-authored-by: Dor Serero <dorserer@amazon.com> Co-authored-by: JounQin <admin@1stg.me>
1 parent d8fc957 commit 4093cb7

6 files changed

Lines changed: 47 additions & 39 deletions

File tree

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@
269269
"test",
270270
"tool"
271271
]
272+
},
273+
{
274+
"login": "dorser",
275+
"name": "dorser",
276+
"avatar_url": "https://avatars2.githubusercontent.com/u/20969462?v=4",
277+
"profile": "https://github.com/dorser",
278+
"contributions": [
279+
"code",
280+
"maintenance"
281+
]
272282
}
273283
],
274284
"repoType": "github",

.changeset/lovely-rings-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prettier-eslint-cli": patch
3+
---
4+
5+
fix(list-different): removed the message at the end of execution

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ Thanks goes to these people ([emoji key][emojis]):
282282
<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>
283283
<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>
284284
<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>
285+
<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>
285286
</tr>
286287
</table>
287288

src/format-files.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,39 +162,41 @@ function formatFilesFromGlobs({
162162
}
163163

164164
function onComplete() {
165-
const isNotSilent = logger.getLevel() !== logger.levels.SILENT;
165+
const isSilent = logger.getLevel() === logger.levels.SILENT || cliOptions.listDifferent;
166166

167167
/* use console.error directly here because
168168
* - we don't want these messages prefixed
169169
* - we want them to go to stderr, not stdout
170170
*/
171-
if (successes.length && isNotSilent) {
172-
console.error(
173-
messages.success({
174-
success: chalk.green('success'),
175-
count: successes.length,
176-
countString: chalk.bold(successes.length)
177-
})
178-
);
179-
}
180-
if (failures.length && isNotSilent) {
181-
process.exitCode = 1;
182-
console.error(
183-
messages.failure({
184-
failure: chalk.red('failure'),
185-
count: failures.length,
186-
countString: chalk.bold(failures.length)
187-
})
188-
);
189-
}
190-
if (unchanged.length && isNotSilent) {
191-
console.error(
192-
messages.unchanged({
193-
unchanged: chalk.gray('unchanged'),
194-
count: unchanged.length,
195-
countString: chalk.bold(unchanged.length)
196-
})
197-
);
171+
if (!isSilent) {
172+
if (successes.length) {
173+
console.error(
174+
messages.success({
175+
success: chalk.green('success'),
176+
count: successes.length,
177+
countString: chalk.bold(successes.length)
178+
})
179+
);
180+
}
181+
if (failures.length) {
182+
process.exitCode = 1;
183+
console.error(
184+
messages.failure({
185+
failure: chalk.red('failure'),
186+
count: failures.length,
187+
countString: chalk.bold(failures.length)
188+
})
189+
);
190+
}
191+
if (unchanged.length) {
192+
console.error(
193+
messages.unchanged({
194+
unchanged: chalk.gray('unchanged'),
195+
count: unchanged.length,
196+
countString: chalk.bold(unchanged.length)
197+
})
198+
);
199+
}
198200
}
199201
resolve({ successes, failures });
200202
}

src/format-files.test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,6 @@ describe('listDifferent', () => {
275275
expect(fsMock.readFile).toHaveBeenCalledTimes(7);
276276
expect(fsMock.writeFile).toHaveBeenCalledTimes(0);
277277

278-
const unchangedOutput = expect.stringMatching(/3.*files were.*unchanged/);
279-
const successOutput = expect.stringMatching(/success.*4.*files/);
280-
expect(console.error).toHaveBeenCalledTimes(2);
281-
expect(console.error).toHaveBeenCalledWith(unchangedOutput);
282-
expect(console.error).toHaveBeenCalledWith(successOutput);
283-
284278
const path =
285279
'/Users/fredFlintstone/Developer/top-secret/footless-carriage/';
286280
expect(console.log).toHaveBeenCalledTimes(4);

test/tests/__snapshots__/cli.spec.js.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ Object {
1717
`;
1818

1919
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`] = `
20-
"can't resolve reference #/definitions/directiveConfigSchema from id #
21-
can't resolve reference #/definitions/directiveConfigSchema from id #
22-
can't resolve reference #/definitions/directiveConfigSchema from id #
23-
can't resolve reference #/definitions/directiveConfigSchema from id #
24-
success formatting 2 files with prettier-eslint
20+
"success formatting 2 files with prettier-eslint
2521
"
2622
`;

0 commit comments

Comments
 (0)