Skip to content

Commit

Permalink
feat(docz-core): detect typescript without config
Browse files Browse the repository at this point in the history
Checks for a tsconfig.json file to initialize config.typescript

Can be overridden by user
  • Loading branch information
rakannimer committed Dec 12, 2019
1 parent 64d05e9 commit bbaecb2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion core/docz-core/src/config/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { get } from 'lodash/fp'

import { Plugin } from '../lib/Plugin'
import * as paths from '../config/paths'
import { doczRcBaseConfig } from './docz'

const getEnv = (val: string | string[], defaultValue: any = null): any =>
envDotProp.get(val, defaultValue, { parse: true })
Expand Down Expand Up @@ -131,7 +132,7 @@ export const setArgs = (yargs: Yargs) => {
.option('typescript', {
alias: 'ts',
type: 'boolean',
default: getEnv('docz.typescript', false),
default: getEnv('docz.typescript', doczRcBaseConfig.typescript),
})
.option('propsParser', {
type: 'boolean',
Expand Down
5 changes: 3 additions & 2 deletions core/docz-core/src/config/docz.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as path from 'path'
import { Arguments } from 'yargs'
import { omit } from 'lodash/fp'
import { omit, merge } from 'lodash/fp'
import { load, loadFrom } from 'load-cfg'
import { merge } from 'lodash/fp'
import detectPort from 'detect-port'
import fs from 'fs-extra'

import * as paths from '../config/paths'
import { Config, Argv } from '../config/argv'
import { Plugin } from '../lib/Plugin'

const toOmit = ['_', '$0', 'version', 'help']
export const doczRcBaseConfig = {
typescript: fs.existsSync(paths.appTsConfig),
themeConfig: {},
themesDir: 'src',
mdxExtensions: ['.md', '.mdx'],
Expand Down
1 change: 1 addition & 0 deletions core/docz-core/src/config/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const docz = resolveApp('.docz')
export const cache = path.resolve(docz, '.cache/')
export const app = path.resolve(docz, 'app/')
export const appPackageJson = resolveApp('package.json')
export const appTsConfig = resolveApp('tsconfig.json')
export const gatsbyConfig = resolveApp('gatsby-config.js')
export const gatsbyBrowser = resolveApp('gatsby-browser.js')
export const gatsbyNode = resolveApp('gatsby-node.js')
Expand Down
5 changes: 0 additions & 5 deletions examples/typescript/doczrc.js

This file was deleted.

0 comments on commit bbaecb2

Please sign in to comment.