Skip to content

Commit

Permalink
fix(docz-core): run init on build if docz is not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer committed Sep 3, 2019
1 parent 2cd87ee commit fe984fd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/docz-core/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ import * as logger from 'signale'

import { parseConfig } from '../config/docz'
import { bundler as gatsby } from '../bundler'
import { getIsFirstInstall } from '../bundler/machine/actions'
import { init } from './init'

export const build = async (args: Arguments<any>) => {
const config = await parseConfig(args)
const bundler = gatsby(config)
const isFirstInstall = getIsFirstInstall()

if (isFirstInstall) {
try {
await init(args)
} catch (err) {
throw new Error(`Failed to initialize docz : ${err.message}`)
}
}

try {
await bundler.build()
Expand Down

0 comments on commit fe984fd

Please sign in to comment.