UNPKG

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