From 08b15d4acfca8fdfd665c0087b65637bb23f4722 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 9 Sep 2020 05:30:39 -0700 Subject: [PATCH] Honor --quiet flag Fixes: #113 --- index.js | 6 ++++-- test.js | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3b1c32d..bf5358e 100755 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ prog 'a glob of files to to test the EcmaScript version against' ) .option('--module', 'use ES modules') + .option('--quiet', 'Quiet mode - only displays warn and error messages') .option('--allow-hash-bang', 'if the code starts with #! treat it as a comment') .option('--not', 'folder or file names to skip', prog.LIST) .action((args, options, logger) => { @@ -78,7 +79,6 @@ prog 'No files were passed in please pass in a list of files to es-check!' ) process.exit(1) - } /** @@ -200,7 +200,9 @@ prog }) process.exit(1) } - logger.error(`ES-Check: there were no ES version matching errors! 🎉`) + if (!options.quiet) { + logger.error(`ES-Check: there were no ES version matching errors! 🎉`) + } }) prog.parse(argsArray) diff --git a/test.js b/test.js index bb48af7..63a11b2 100644 --- a/test.js +++ b/test.js @@ -128,3 +128,12 @@ it('👌 Es Check skips versions included in the not flag', (done) => { done() }); }); + +it('🎉 Es Check does not output anything in --quiet mode', (done) => { + exec('node index.js --quiet es5 ./tests/es5.js', (err, stdout, stderr) => { + assert.equal(err, null) + assert.equal(stdout, '') + assert.equal(stderr, '') + done() + }) +})