Skip to content

Commit

Permalink
fix(docz-core): wait for app to be ready before opening the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer committed Aug 27, 2019
1 parent 777a396 commit c5cd14d
Show file tree
Hide file tree
Showing 3 changed files with 2,953 additions and 202 deletions.
2 changes: 2 additions & 0 deletions core/docz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"signale": "^1.4.0",
"titleize": "^2.1.0",
"typescript": "3.5.3",
"wait-on": "^3.3.0",
"xstate": "^4.6.7",
"yargs": "^13.3.0"
},
Expand All @@ -55,6 +56,7 @@
"@types/resolve": "^0.0.8",
"@types/shelljs": "^0.8.5",
"@types/signale": "^1.2.1",
"@types/wait-on": "^3.2.0",
"cpy": "^7.3.0",
"docz-rollup": "^2.0.0-rc.1",
"eslint-config-docz-ts": "^2.0.0-rc.1"
Expand Down
13 changes: 11 additions & 2 deletions core/docz-core/src/bundler/machine/services/exec-dev-command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import spawn from 'cross-spawn'
import sh from 'shelljs'

import waitOn from 'wait-on'
import { ServerMachineCtx } from '../context'
import { openBrowser } from '../../../utils/open-browser'
import * as paths from '../../../config/paths'

export const execDevCommand = async ({ args }: ServerMachineCtx) => {
sh.cd(paths.docz)
spawn('yarn', ['dev', '--port', `${args.port}`], { stdio: 'inherit' })
openBrowser(`http://${args.host}:${args.port}`)
const url = `http://${args.host}:${args.port}`
console.log()
console.log('Buiding app')
await waitOn({
resources: [url],
timeout: 30000,
})
console.log()
console.log('App ready on ' + url)
openBrowser(url)
}

0 comments on commit c5cd14d

Please sign in to comment.