Skip to content

Commit

Permalink
Linter of CLI docs. Fixes #377.
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Mar 12, 2016
1 parent fdf9636 commit 286725d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/usage.md
Expand Up @@ -7,8 +7,6 @@ Dredd may be configured from the command line, from a configuration, or from the
To see how to use the CLI interface, type `dredd --help` at the command line.

```
dredd --help
Usage:
$ dredd init
Expand All @@ -23,13 +21,15 @@ Options:
blueprint and compile transactions. [default: null]
--hookfiles, -f Specifies a pattern to match files with before/after
hooks for running tests [default: null]
--language, -a Language of hookfiles. Possible options are: nodejs,
ruby, python, php, perl, go [default: "nodejs"]
--sandbox, -b Load and run non trusted hooks code in sandboxed
container [default: false]
--server, -g Run API backend server command and kill it after Dredd
execution. E.g. `rails server` [default: null]
--server-wait Set delay time in seconds between running a server and
test run. [default: 3]
--init, -i Run interactive configuration. Creates .dredd.yml
--init, -i Run interactive configuration. Creates dredd.yml
configuration file. [default: false]
--custom, -j Pass custom key-value configuration data delimited by a
colon. E.g. -j 'a:b' [default: []]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"changelist": "github-changes -o apiaryio -r dredd --only-pulls --use-commit-body --file CHANGELOG-Generated.md -a",
"lint": "coffeelint ./src",
"lint": "./scripts/lint",
"compile": "coffee -b -c -o lib/ src/",
"pretest": "npm run compile",
"test": "./scripts/test",
Expand Down
9 changes: 9 additions & 0 deletions scripts/lint
@@ -0,0 +1,9 @@
#!/bin/bash
# Runs all linters.


# CoffeeScript linter
coffeelint ./src

# Ensure the docs about CLI are up-to-date
coffee ./scripts/lint-cli-docs.coffee
20 changes: 20 additions & 0 deletions scripts/lint-cli-docs.coffee
@@ -0,0 +1,20 @@
# Ensures the CLI docs are up to date.


fs = require 'fs'
{assert} = require 'chai'
execSync = require 'sync-exec'


usageDocs = fs.readFileSync 'docs/usage.md', 'utf-8'

helpOutput = execSync('bin/dredd --help')?.stderr?.trim?() or ''
helpOutput = (line.trimRight() for line in helpOutput.split(/\n/)).join('\n') # without trailing whitespace
helpOutput = """```\n#{helpOutput}\n```""" # turning to Markdown code block


try
assert.include usageDocs, helpOutput
catch e
console.error 'Documentation of CLI in docs/usage.md is not up to date.'
process.exit 1

0 comments on commit 286725d

Please sign in to comment.