Skip to content

Commit

Permalink
fix(docz-core): add src as prefix on ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 29, 2019
1 parent ad85e40 commit 2bae93b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions core/docz-core/src/states/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relative } from 'path'
import { join, relative } from 'path'
import chokidar from 'chokidar'
import fastglob from 'fast-glob'
import { State, Params } from '../lib/DataServer'
Expand All @@ -9,12 +9,15 @@ import { Config } from '../config/argv'
import { docgen } from '../utils/docgen'

const getPattern = (config: Config) => {
const { typescript, ignore } = config
return [
typescript ? '**/*.{ts,tsx}' : '**/*.{js,jsx,mjs}',
'!**/node_modules',
'!**/doczrc.js',
].concat(ignore.map(entry => `!**/${entry}`))
const { typescript: ts, ignore, src: source } = config
const src = relative(paths.root, source)
return ignore
.map(entry => `!**/${entry}`)
.concat([
join(src, ts ? '**/*.{ts,tsx}' : '**/*.{js,jsx,mjs}'),
'!**/node_modules',
'!**/doczrc.js',
])
}

export const mapToArray = (map: any = []) =>
Expand All @@ -24,8 +27,7 @@ export const mapToArray = (map: any = []) =>
})
.filter(Boolean)

const initial = (config: Config) => async (p: Params) => {
const pattern = getPattern(config)
const initial = (config: Config, pattern: string[]) => async (p: Params) => {
const files = await fastglob<string>(pattern, { cwd: paths.root })
const metadata = await docgen(files, config)
p.setState('props', flatten(mapToArray(metadata)))
Expand Down Expand Up @@ -59,7 +61,7 @@ export const state = (config: Config): State => {
return {
id: 'props',
start: async params => {
const addInitial = initial(config)
const addInitial = initial(config, pattern)
await addInitial(params)
watcher.on('change', add(params, config))
watcher.on('unlink', remove(params))
Expand Down

0 comments on commit 2bae93b

Please sign in to comment.