Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit f8af22b

Browse files
Kerumenrakannimer
authored andcommitted
chore(docz-core): fix resolveApp when called from the docz project (#1189)
1 parent 1bcbe1e commit f8af22b

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

core/docz-core/src/config/paths.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as fs from 'fs'
22
import * as path from 'path'
33
import * as resolve from 'resolve'
44

5+
import { Config } from './argv'
6+
57
export const ensureSlash = (filepath: any, needsSlash: boolean) => {
68
const hasSlash = filepath.endsWith('/')
79

@@ -15,41 +17,38 @@ export const ensureSlash = (filepath: any, needsSlash: boolean) => {
1517
}
1618

1719
export const root = fs.realpathSync(process.cwd())
18-
export const resolveApp = (to: string) => path.resolve(root, to)
19-
export const resolveOwn = (to: string) => path.resolve(__dirname, '../', to)
20+
const IS_DOCZ_PROJECT = path.parse(root).base === '.docz'
21+
22+
export const resolveApp = (to: string) =>
23+
path.resolve(root, IS_DOCZ_PROJECT ? '../' : './', to)
2024

21-
export const checkIsDoczProject = (config: any) => {
25+
export const checkIsDoczProject = (config: Config) => {
2226
return path.parse(config.root || root).base === '.docz'
2327
}
2428

25-
export const getRootDir = (config: any) => {
29+
export const getRootDir = (config: Config) => {
2630
const isDoczProject = checkIsDoczProject(config)
2731
return isDoczProject ? path.resolve(root, '../') : root
2832
}
2933

30-
export const getThemesDir = (config: { themesDir: string }) => {
34+
export const getThemesDir = (config: Config) => {
3135
// resolve normalizes the new path and removes trailing slashes
3236
return path.resolve(path.join(getRootDir(config), config.themesDir))
3337
}
3438

3539
export interface Paths {
3640
root: string
3741
templates: string
38-
packageJson: string
3942
servedPath: (base: string) => string
4043

4144
docz: string
4245
app: string
4346
cache: string
44-
appPublic: string
45-
appNodeModules: string
4647
appPackageJson: string
47-
appYarnLock: string
4848
gatsbyConfig: string
4949
gatsbyBrowser: string
5050
gatsbyNode: string
5151
gatsbySSR: string
52-
ownNodeModules: string
5352

5453
checkIsDoczProject: (config: any) => boolean
5554
getRootDir: (config: any) => string
@@ -66,19 +65,12 @@ export interface Paths {
6665

6766
export const templates = path.join(resolve.sync('docz-core'), '../templates')
6867

69-
export const packageJson = resolveApp('package.json')
7068
export const servedPath = (base: string) => ensureSlash(base, true)
7169

72-
const IS_DOCZ_PROJECT = path.parse(root).base === '.docz'
73-
74-
export const docz = resolveApp(IS_DOCZ_PROJECT ? './' : '.docz')
70+
export const docz = resolveApp('.docz')
7571
export const cache = path.resolve(docz, '.cache/')
7672
export const app = path.resolve(docz, 'app/')
77-
export const appPublic = path.resolve(docz, 'public/')
78-
export const appNodeModules = resolveApp('node_modules')
7973
export const appPackageJson = resolveApp('package.json')
80-
export const appYarnLock = resolveOwn('yarn.lock')
81-
export const ownNodeModules = resolveOwn('node_modules')
8274
export const gatsbyConfig = resolveApp('gatsby-config.js')
8375
export const gatsbyBrowser = resolveApp('gatsby-browser.js')
8476
export const gatsbyNode = resolveApp('gatsby-node.js')

0 commit comments

Comments
 (0)