Skip to content

Commit

Permalink
fix: immutable merge with lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 11, 2019
1 parent 0531d65 commit 2fe94d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/docz-core/src/config/babel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { load } from 'load-cfg'
import { merge } from 'lodash'
import { merge } from 'lodash/fp'
import getCacheIdentifier from 'react-dev-utils/getCacheIdentifier'

import { Config, Env } from '../config/argv'
Expand Down
2 changes: 1 addition & 1 deletion core/docz-core/src/config/docz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as path from 'path'
import { Arguments } from 'yargs'
import { omit } from 'lodash/fp'
import { load, loadFrom } from 'load-cfg'
import { merge } from 'lodash/fp'
import detectPort from 'detect-port'
import merge from 'lodash/merge'

import * as paths from '../config/paths'
import { BabelRC } from '../config/babel'
Expand Down
10 changes: 4 additions & 6 deletions core/docz-core/src/states/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ const getInitialConfig = (config: Config): Payload => {
}
}

const updateConfig = (config: Config) => async (p: Params) => {
const initial = getInitialConfig(config)
const update = async (params: Params, initial: Payload) => {
const next = load('docz', initial, true, true)
p.setState('config', next)
params.setState('config', next)
}

export const state = (config: Config): State => {
const initial = getInitialConfig(config)
const watcher = chokidar.watch(finds('docz'), {
cwd: paths.root,
ignored: /(((^|[\/\\])\..+)|(node_modules))/,
Expand All @@ -55,10 +55,8 @@ export const state = (config: Config): State => {
return {
id: 'config',
start: async params => {
const update = updateConfig(config)
const fn = async () => update(params)
const fn = async () => update(params, initial)

await update(params)
watcher.on('add', fn)
watcher.on('change', fn)
watcher.on('unlink', fn)
Expand Down
3 changes: 1 addition & 2 deletions other-packages/load-cfg/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs-extra'
import * as path from 'path'
import * as findup from 'find-up'
import { merge } from 'lodash'
import { merge } from 'lodash/fp'

export const loadFile = (filepath: string, noCache?: boolean) => {
require('@babel/register')({
Expand Down Expand Up @@ -54,7 +54,6 @@ export function load<C = any>(
? merge(defaultConfig, file)
: { ...defaultConfig, ...file }
: file

// tslint:disable
return next
}
Expand Down

0 comments on commit 2fe94d4

Please sign in to comment.