Skip to content

Commit

Permalink
fix(docz-core): parse port when running serve
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer committed Feb 6, 2020
1 parent 2e6e7aa commit 29d0edd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/docz-core/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const cli = () => {
await commands.build(args)
process.exit()
})
.command('serve', 'serve dir as static site', setArgs, async () => {
.command('serve', 'serve dir as static site', setArgs, async args => {
setEnv('production')
await commands.serve()
await commands.serve(args)
process.exit()
})
.demandCommand()
Expand Down
14 changes: 13 additions & 1 deletion core/docz-core/src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import sh from 'shelljs'
import { Arguments } from 'yargs'

import * as paths from '../config/paths'
import { spawnSync } from '../utils/spawn'
import { parseConfig } from '../config/docz'

export const serve = async () => {
export const serve = async (args: Arguments<any>) => {
const config = await parseConfig(args)
const cliArgs = ['run', 'serve']

if (config.port) {
cliArgs.push('--')
// Append gatsby option `port`to CLI args
// https://www.gatsbyjs.org/docs/cheat-sheet/#cheat_sheet-text
cliArgs.push('--port')
cliArgs.push(String(config.port))
}

sh.cd(paths.docz)
spawnSync('npm', cliArgs)
}

0 comments on commit 29d0edd

Please sign in to comment.