From 5be3febdc5b272d2270a053829788f72da3fa5e7 Mon Sep 17 00:00:00 2001 From: Dor Serero Date: Mon, 20 Jul 2020 21:31:15 +0300 Subject: [PATCH] fix(list-different): removed the message at the end of execution (#111) --- .all-contributorsrc | 10 +++++++ README.md | 1 + src/format-files.js | 58 +++++++++++++++++++++------------------- src/format-files.test.js | 6 ----- 4 files changed, 41 insertions(+), 34 deletions(-) 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/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);