diff --git a/cli.js b/cli.js index 0303576..dea69d4 100755 --- a/cli.js +++ b/cli.js @@ -58,6 +58,7 @@ const cli = meow( ' -d, --diff ignore unchanged lines (affects Travis only)', ' --reporter=REPORTER use a custom vfile-reporter', ' --stdin read from stdin', + ' --silently-ignore do not fail when given ignored files', '', 'When no input files are given, searches for markdown and text', 'files in the current directory, `doc`, and `docs`.', @@ -79,7 +80,8 @@ const cli = meow( diff: {type: 'boolean', alias: 'd'}, reporter: {type: 'string'}, quiet: {type: 'boolean', alias: 'q'}, - why: {type: 'boolean', alias: 'w'} + why: {type: 'boolean', alias: 'w'}, + silentlyIgnore: {type: 'boolean'} } } ) @@ -107,6 +109,10 @@ if (cli.flags.stdin) { globs = cli.input } +if (cli.flags.silentlyIgnore) { + silentlyIgnore = true +} + engine( { processor: unified(), diff --git a/test/cli.js b/test/cli.js index 5650c11..89f39e3 100644 --- a/test/cli.js +++ b/test/cli.js @@ -358,5 +358,32 @@ test('alex-cli', function (t) { }) }) + t.test('silently-ignore flag', function (t) { + t.plan(1) + + childProcess.exec( + './cli.js --silently-ignore "example.md"', + (error, stdout, stderr) => { + t.deepEqual( + [error, stderr, stdout], + [null, '', ''], + 'should exit successfully with --silently-ignore flag' + ) + } + ) + }) + + t.test('without silently-ignore flag', function (t) { + t.plan(1) + + childProcess.exec('./cli.js example.md', (error, stdout, stderr) => { + t.deepEqual( + [error && error.code, /1 error/.test(stderr), stdout], + [1, true, ''], + 'should fail without --silently-ignore flag' + ) + }) + }) + t.end() })