|
1 | 1 | import chalk from 'chalk'
|
2 | 2 | import commandExists from 'command-exists'
|
3 | 3 | import execa from 'execa'
|
4 |
| -import { copyFileSync, ensureDirSync, ensureFileSync, existsSync, mkdirpSync, removeSync } from 'fs-extra' |
| 4 | +import { copyFileSync, ensureFileSync, existsSync, removeSync } from 'fs-extra' |
5 | 5 | import minimist from 'minimist'
|
6 | 6 | import path from 'path'
|
7 | 7 | import 'hard-rejection/register'
|
8 | 8 |
|
9 |
| -const docsPath = '../ember-api-docs-data'; |
| 9 | +const docsPath = '../ember-api-docs-data' |
10 | 10 |
|
11 | 11 | const argv = minimist(process.argv.slice(2))
|
12 | 12 |
|
13 |
| -const { project, version, install, build } = argv |
| 13 | +const { project, version, install } = argv |
14 | 14 |
|
15 | 15 | const exit = function exit() {
|
16 | 16 | console.log(...arguments)
|
17 | 17 | process.exit(1)
|
18 | 18 | }
|
19 | 19 |
|
20 |
| -const runCmd = async (cmd, path, args = []) => { |
| 20 | +async function runCmd (cmd, path, args = []) { |
21 | 21 | console.log(chalk.underline(`Running '${chalk.green(cmd)}' in ${path}`))
|
22 | 22 | const executedCmd = await execa(cmd, args, { cwd: path, shell: true, stdio: 'inherit' })
|
23 | 23 |
|
24 |
| - if (executedCmd.failed) { |
25 |
| - console.error(executedCmd.stdout) |
26 |
| - console.error(executedCmd.stderr) |
27 |
| - process.exit(1) |
28 |
| - |
29 |
| - } |
30 |
| - console.log(executedCmd.stdout + '\n') |
31 |
| - } catch (error) { |
32 |
| - console.log(error) |
| 24 | + if (executedCmd.failed) { |
| 25 | + console.error(executedCmd.stdout) |
| 26 | + console.error(executedCmd.stderr) |
33 | 27 | process.exit(1)
|
34 | 28 | }
|
| 29 | + |
| 30 | + console.log(executedCmd.stdout + '\n') |
35 | 31 | }
|
36 |
| -;(async () => { |
| 32 | + |
| 33 | +(async () => { |
37 | 34 | if (!project || !version) {
|
38 | 35 | exit(
|
39 | 36 | chalk.red('Both project and version args are required.\n'),
|
@@ -79,7 +76,7 @@ const runCmd = async (cmd, path, args = []) => {
|
79 | 76 |
|
80 | 77 | let destination = `${docsPath}/s3-docs/v${version}/${project}-docs.json`
|
81 | 78 | ensureFileSync(destination)
|
82 |
| - const projYuiDocFile = destination; |
| 79 | + const projYuiDocFile = destination |
83 | 80 | removeSync(projYuiDocFile)
|
84 | 81 | removeSync(`${docsPath}/json-docs/${project}/${version}`)
|
85 | 82 |
|
|
0 commit comments