1 | #!/usr/bin/env node
|
2 | 'use strict';
|
3 |
|
4 | const fs = require('fs');
|
5 | const path = require('path');
|
6 | const stripAnsi = require('strip-ansi');
|
7 | const execSync = require('child_process').execSync;
|
8 |
|
9 |
|
10 |
|
11 | const output = execSync(
|
12 | `${path.join(__dirname, 'batfish.js')} --help`
|
13 | ).toString();
|
14 |
|
15 | const tidyOutput = stripAnsi(
|
16 | output.replace(/\n[ ]{2}/g, '\n').replace(/(^\r?\n+|\r?\n+$)/g, '')
|
17 | );
|
18 |
|
19 | const docs = `# The Batfish CLI
|
20 |
|
21 | The following is output by \`batfish --help\`:
|
22 |
|
23 | \`\`\`
|
24 | ${tidyOutput}
|
25 | \`\`\`
|
26 | `;
|
27 |
|
28 | fs.writeFileSync(path.join(__dirname, '../docs/cli.md'), docs);
|