Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): prevent delete entire app folder on build
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 11, 2018
1 parent 715e4fb commit e345896
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/docz-core/src/Entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const writeAppFiles = async (config: Config, dev: boolean): Promise<void> => {
isProd: !dev,
})

await fs.remove(paths.rootJs)
await fs.remove(paths.indexJs)
await touch(paths.rootJs, rawRootJs)
await touch(paths.indexJs, rawIndexJs)
}
Expand Down
7 changes: 2 additions & 5 deletions packages/docz-core/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as fs from 'fs-extra'
import logger from 'signale'
import envDotProp from 'env-dot-prop'

import * as paths from '../config/paths'
import * as states from '../states'
import { loadConfig } from '../utils/load-config'
import { webpack } from '../bundlers'
Expand All @@ -19,11 +17,10 @@ export const build = async (args: Config) => {
const dataServer = new DataServer()

try {
await fs.remove(paths.app)
await Entries.writeApp(config)

dataServer.register([states.entries(config), states.config(config)])

await dataServer.init()
await Entries.writeApp(config)

await run('onPreBuild')
await bundler.build(await bundler.getConfig(env))
Expand Down
8 changes: 1 addition & 7 deletions packages/docz-core/src/commands/dev.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import * as fs from 'fs-extra'
import logger from 'signale'
import detectPort from 'detect-port'
import envDotProp from 'env-dot-prop'

import * as paths from '../config/paths'
import * as states from '../states'

import { Config } from './args'
import { DataServer } from '../DataServer'
import { webpack } from '../bundlers'
Expand Down Expand Up @@ -36,14 +33,11 @@ export const dev = async (args: Config) => {
)

try {
await fs.remove(paths.rootJs)
await fs.remove(paths.indexJs)
await Entries.writeApp(newConfig, true)

dataServer.register([states.entries(newConfig), states.config(newConfig)])

await dataServer.init()
await dataServer.listen()
await Entries.writeApp(newConfig, true)
} catch (err) {
logger.fatal('Failed to process your server:', err)
process.exit(1)
Expand Down

0 comments on commit e345896

Please sign in to comment.