-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
test.js
83 lines (73 loc) · 2.83 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'use strict'
var path = require('path')
var execa = require('execa')
var test = require('tape')
var join = path.join
test('remark-cli', function(t) {
t.plan(2)
t.test('should show help on `--help`', function(st) {
var bin = join('packages', 'remark-cli', 'cli.js')
st.plan(1)
execa(bin, ['--help']).then(function(result) {
st.equal(
result.stdout,
[
'Usage: remark [options] [path | glob ...]',
'',
' CLI to process markdown with remark using plugins',
'',
'Options:',
'',
' -h --help output usage information',
' -v --version output version number',
' -o --output [path] specify output location',
' -r --rc-path <path> specify configuration file',
' -i --ignore-path <path> specify ignore file',
' -s --setting <settings> specify settings',
' -e --ext <extensions> specify extensions',
' -u --use <plugins> use plugins',
' -w --watch watch for changes and reprocess',
' -q --quiet output only warnings and errors',
' -S --silent output only errors',
' -f --frail exit with 1 on warnings',
' -t --tree specify input and output as syntax tree',
' --report <reporter> specify reporter',
' --file-path <path> specify path to process as',
' --tree-in specify input as syntax tree',
' --tree-out output syntax tree',
' --inspect output formatted syntax tree',
' --[no-]stdout specify writing to stdout (on by default)',
' --[no-]color specify color in report (on by default)',
' --[no-]config search for configuration files (on by default)',
' --[no-]ignore search for ignore files (on by default)',
'',
'Examples:',
'',
' # Process `input.md`',
' $ remark input.md -o output.md',
'',
' # Pipe',
' $ remark < input.md > output.md',
'',
' # Rewrite all applicable files',
' $ remark . -o'
].join('\n'),
'should show help'
)
})
})
t.test('should show version on `--version`', function(st) {
var bin = join('packages', 'remark-cli', 'cli.js')
st.plan(2)
execa(bin, ['--version']).then(function(result) {
st.ok(
/remark: \d+\.\d+\.\d+/.test(result.stdout),
'should include remark version'
)
st.ok(
/remark-cli: \d+\.\d+\.\d+/.test(result.stdout),
'should include remark-cli version'
)
})
})
})