|
1 | | -import {URL, fileURLToPath} from 'node:url' |
| 1 | +import assert from 'node:assert/strict' |
| 2 | +import {fileURLToPath} from 'node:url' |
| 3 | +import test from 'node:test' |
2 | 4 | import {execa} from 'execa' |
3 | | -import test from 'tape' |
4 | 5 |
|
5 | | -test('remark-cli', (t) => { |
6 | | - t.plan(2) |
7 | | - |
8 | | - t.test('should show help on `--help`', (t) => { |
| 6 | +test('remark-cli', async (t) => { |
| 7 | + await t.test('should show help on `--help`', async () => { |
9 | 8 | const bin = fileURLToPath(new URL('cli.js', import.meta.url)) |
10 | 9 |
|
11 | | - t.plan(1) |
| 10 | + const result = await execa(bin, ['--help']) |
12 | 11 |
|
13 | | - execa(bin, ['--help']).then((result) => { |
14 | | - t.equal( |
15 | | - result.stdout, |
16 | | - [ |
17 | | - 'Usage: remark [options] [path | glob ...]', |
18 | | - '', |
19 | | - ' Command line interface to inspect and change markdown files with remark', |
20 | | - '', |
21 | | - 'Options:', |
22 | | - '', |
23 | | - ' -h --help output usage information', |
24 | | - ' -v --version output version number', |
25 | | - ' -o --output [path] specify output location', |
26 | | - ' -r --rc-path <path> specify configuration file', |
27 | | - ' -i --ignore-path <path> specify ignore file', |
28 | | - ' -s --setting <settings> specify settings', |
29 | | - ' -e --ext <extensions> specify extensions', |
30 | | - ' -u --use <plugins> use plugins', |
31 | | - ' -w --watch watch for changes and reprocess', |
32 | | - ' -q --quiet output only warnings and errors', |
33 | | - ' -S --silent output only errors', |
34 | | - ' -f --frail exit with 1 on warnings', |
35 | | - ' -t --tree specify input and output as syntax tree', |
36 | | - ' --report <reporter> specify reporter', |
37 | | - ' --file-path <path> specify path to process as', |
38 | | - ' --ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd', |
39 | | - ' --ignore-pattern <globs> specify ignore patterns', |
40 | | - ' --silently-ignore do not fail when given ignored files', |
41 | | - ' --tree-in specify input as syntax tree', |
42 | | - ' --tree-out output syntax tree', |
43 | | - ' --inspect output formatted syntax tree', |
44 | | - ' --[no-]stdout specify writing to stdout (on by default)', |
45 | | - ' --[no-]color specify color in report (on by default)', |
46 | | - ' --[no-]config search for configuration files (on by default)', |
47 | | - ' --[no-]ignore search for ignore files (on by default)', |
48 | | - '', |
49 | | - 'Examples:', |
50 | | - '', |
51 | | - ' # Process `input.md`', |
52 | | - ' $ remark input.md -o output.md', |
53 | | - '', |
54 | | - ' # Pipe', |
55 | | - ' $ remark < input.md > output.md', |
56 | | - '', |
57 | | - ' # Rewrite all applicable files', |
58 | | - ' $ remark . -o' |
59 | | - ].join('\n'), |
60 | | - 'should show help' |
61 | | - ) |
62 | | - }) |
| 12 | + assert.equal( |
| 13 | + result.stdout, |
| 14 | + [ |
| 15 | + 'Usage: remark [options] [path | glob ...]', |
| 16 | + '', |
| 17 | + ' Command line interface to inspect and change markdown files with remark', |
| 18 | + '', |
| 19 | + 'Options:', |
| 20 | + '', |
| 21 | + ' -h --help output usage information', |
| 22 | + ' -v --version output version number', |
| 23 | + ' -o --output [path] specify output location', |
| 24 | + ' -r --rc-path <path> specify configuration file', |
| 25 | + ' -i --ignore-path <path> specify ignore file', |
| 26 | + ' -s --setting <settings> specify settings', |
| 27 | + ' -e --ext <extensions> specify extensions', |
| 28 | + ' -u --use <plugins> use plugins', |
| 29 | + ' -w --watch watch for changes and reprocess', |
| 30 | + ' -q --quiet output only warnings and errors', |
| 31 | + ' -S --silent output only errors', |
| 32 | + ' -f --frail exit with 1 on warnings', |
| 33 | + ' -t --tree specify input and output as syntax tree', |
| 34 | + ' --report <reporter> specify reporter', |
| 35 | + ' --file-path <path> specify path to process as', |
| 36 | + ' --ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd', |
| 37 | + ' --ignore-pattern <globs> specify ignore patterns', |
| 38 | + ' --silently-ignore do not fail when given ignored files', |
| 39 | + ' --tree-in specify input as syntax tree', |
| 40 | + ' --tree-out output syntax tree', |
| 41 | + ' --inspect output formatted syntax tree', |
| 42 | + ' --[no-]stdout specify writing to stdout (on by default)', |
| 43 | + ' --[no-]color specify color in report (on by default)', |
| 44 | + ' --[no-]config search for configuration files (on by default)', |
| 45 | + ' --[no-]ignore search for ignore files (on by default)', |
| 46 | + '', |
| 47 | + 'Examples:', |
| 48 | + '', |
| 49 | + ' # Process `input.md`', |
| 50 | + ' $ remark input.md -o output.md', |
| 51 | + '', |
| 52 | + ' # Pipe', |
| 53 | + ' $ remark < input.md > output.md', |
| 54 | + '', |
| 55 | + ' # Rewrite all applicable files', |
| 56 | + ' $ remark . -o' |
| 57 | + ].join('\n'), |
| 58 | + 'should show help' |
| 59 | + ) |
63 | 60 | }) |
64 | 61 |
|
65 | | - t.test('should show version on `--version`', (t) => { |
| 62 | + await t.test('should show version on `--version`', async () => { |
66 | 63 | const bin = fileURLToPath(new URL('cli.js', import.meta.url)) |
67 | 64 |
|
68 | | - t.plan(2) |
| 65 | + const result = await execa(bin, ['--version']) |
69 | 66 |
|
70 | | - execa(bin, ['--version']).then((result) => { |
71 | | - t.ok( |
72 | | - /remark: \d+\.\d+\.\d+/.test(result.stdout), |
73 | | - 'should include remark version' |
74 | | - ) |
| 67 | + assert.ok( |
| 68 | + /remark: \d+\.\d+\.\d+/.test(result.stdout), |
| 69 | + 'should include remark version' |
| 70 | + ) |
75 | 71 |
|
76 | | - t.ok( |
77 | | - /remark-cli: \d+\.\d+\.\d+/.test(result.stdout), |
78 | | - 'should include remark-cli version' |
79 | | - ) |
80 | | - }) |
| 72 | + assert.ok( |
| 73 | + /remark-cli: \d+\.\d+\.\d+/.test(result.stdout), |
| 74 | + 'should include remark-cli version' |
| 75 | + ) |
81 | 76 | }) |
82 | 77 | }) |
0 commit comments