Skip to content

Commit

Permalink
feat: allow theme file to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Jan 29, 2024
1 parent 6528850 commit ab502b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class Config implements IConfig {
this.npmRegistry = this.scopedEnvVar('NPM_REGISTRY') || this.pjson.oclif.npmRegistry

if (!this.scopedEnvVarTrue('DISABLE_THEME')) {
const {theme} = await this.loadThemes()
const {theme} = await this.loadTheme()
this.theme = theme
}

Expand Down Expand Up @@ -401,16 +401,17 @@ export class Config implements IConfig {
}
}

public async loadThemes(): Promise<{
public async loadTheme(): Promise<{
file: string
theme: Theme | undefined
}> {
const file = resolve(this.configDir, 'theme.json')
const themes = await safeReadJson<Record<string, string>>(file)
const theme = themes ? parseTheme(themes) : undefined
const file = this.pjson.oclif.theme
? resolve(this.root, this.pjson.oclif.theme)
: resolve(this.configDir, 'theme.json')
const themeRaw = await safeReadJson<Record<string, string>>(file)
return {
file,
theme,
theme: themeRaw ? parseTheme(themeRaw) : undefined,
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/interfaces/pjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ export namespace PJSON {
identifier?: string
sign?: string
}
windows?: {
homepage?: string
keypath?: string
name?: string
}
plugins?: string[]
repositoryPrefix?: string
schema?: number
state?: 'beta' | 'deprecated' | string
theme?: string
topicSeparator?: ' ' | ':'
topics?: {
[k: string]: {
Expand All @@ -72,6 +68,11 @@ export namespace PJSON {
}
s3: S3
}
windows?: {
homepage?: string
keypath?: string
name?: string
}
}
version: string
}
Expand Down

0 comments on commit ab502b4

Please sign in to comment.