Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.',
Expand All @@ -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'}
}
}
)
Expand Down Expand Up @@ -107,6 +109,10 @@ if (cli.flags.stdin) {
globs = cli.input
}

if (cli.flags.silentlyIgnore) {
silentlyIgnore = true
}

engine(
{
processor: unified(),
Expand Down
27 changes: 27 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})