From 4093cb7830d49fd8cda23fe33008694dc61074a6 Mon Sep 17 00:00:00 2001 From: dorser Date: Thu, 25 Aug 2022 13:42:57 +0300 Subject: [PATCH] fix(list-different): removed the message at the end of execution (#288) Co-authored-by: Dor Serero Co-authored-by: JounQin --- .all-contributorsrc | 10 ++++ .changeset/lovely-rings-cry.md | 5 ++ README.md | 1 + src/format-files.js | 58 ++++++++++++----------- src/format-files.test.js | 6 --- test/tests/__snapshots__/cli.spec.js.snap | 6 +-- 6 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 .changeset/lovely-rings-cry.md diff --git a/.all-contributorsrc b/.all-contributorsrc index 49947be..99d2af4 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -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", diff --git a/.changeset/lovely-rings-cry.md b/.changeset/lovely-rings-cry.md new file mode 100644 index 0000000..0e10356 --- /dev/null +++ b/.changeset/lovely-rings-cry.md @@ -0,0 +1,5 @@ +--- +"prettier-eslint-cli": patch +--- + +fix(list-different): removed the message at the end of execution diff --git a/README.md b/README.md index 0e7a6e9..eeb4ffd 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ Thanks goes to these people ([emoji key][emojis]):
Glen Whitney

🚧
Rebecca Vest

💻
JounQin

💬 💻 🎨 📖 🤔 🚇 🚧 🔌 📆 👀 ⚠️ 🔧 +
dorser

💻 🚧 diff --git a/src/format-files.js b/src/format-files.js index 610934d..60486db 100644 --- a/src/format-files.js +++ b/src/format-files.js @@ -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 }); } diff --git a/src/format-files.test.js b/src/format-files.test.js index cb96654..4718391 100644 --- a/src/format-files.test.js +++ b/src/format-files.test.js @@ -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); diff --git a/test/tests/__snapshots__/cli.spec.js.snap b/test/tests/__snapshots__/cli.spec.js.snap index b51dd89..60c1101 100644 --- a/test/tests/__snapshots__/cli.spec.js.snap +++ b/test/tests/__snapshots__/cli.spec.js.snap @@ -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 " `;