* @returns {Promise }
()
| 9 | * @returns {Promise<void>} |
| 10 | */ |
| 11 | async function updateDocs() { |
| 12 | const { execaNode } = await import("execa"); |
| 13 | const { stdout: cliOptions } = await execaNode( |
| 14 | resolve(__dirname, "../packages/webpack-cli/bin/cli.js"), |
| 15 | ["--help=verbose", "--no-color"], |
| 16 | { |
| 17 | cwd: __dirname, |
| 18 | nodeOptions: [`--import=${pathToFileURL(resolve(__dirname, "./set-blocking.js"))}`], |
| 19 | }, |
| 20 | ); |
| 21 | |
| 22 | // format output for markdown |
| 23 | const mdContent = ["```\n", cliOptions, "\n```\n"].join(""); |
| 24 | |
| 25 | // create OPTIONS.md |
| 26 | writeFileSync("OPTIONS.md", mdContent); |
| 27 | |
| 28 | // serve options |
| 29 | const { stdout: serveOptions } = await execaNode( |
| 30 | resolve(__dirname, "../packages/webpack-cli/bin/cli.js"), |
| 31 | ["serve", "--help", "--no-color"], |
| 32 | { |
| 33 | cwd: __dirname, |
| 34 | nodeOptions: [`--import=${resolve(__dirname, "./set-blocking.js")}`], |
| 35 | }, |
| 36 | ); |
| 37 | |
| 38 | // format output for markdown |
| 39 | const serveContent = ["```\n", serveOptions, "\n```\n"].join(""); |
| 40 | |
| 41 | // create SERVE.md |
| 42 | writeFileSync(`SERVE-OPTIONS-v${majorDevServerVersion}.md`, serveContent); |
| 43 | |
| 44 | console.log(`Successfully updated "OPTIONS.md" and "SERVE-OPTIONS-v${majorDevServerVersion}.md"`); |
| 45 | } |
| 46 | |
| 47 | try { |
| 48 | // eslint-disable-next-line unicorn/prefer-top-level-await |