Skip to content

Commit

Permalink
feat: use experimentalDarkMode:!0 as main entry, add fallback main …
Browse files Browse the repository at this point in the history
…file path #3
  • Loading branch information
subframe7536 committed Oct 30, 2024
1 parent bd8ee9e commit 0bb433d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/manager/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { config } from '../config'
import { mainBakPath, mainPath } from '../path'
import { BaseFileManager } from './base'

const entry = 'backgroundColor:r.getBackgroundColor()'
const entry = 'experimentalDarkMode:!0'

export class MainFileManager extends BaseFileManager {
constructor() {
super(mainPath, mainBakPath)
}

patch(content: string): Promisable<string> {
config.electron.backgroundColor ??= 'r.getBackgroundColor()'
return content.replace(
return content.replaceAll(
entry,
JSON.stringify(config.electron).slice(1, -1),
`${entry},${JSON.stringify(config.electron).slice(1, -1)}`,
)
}
}
4 changes: 3 additions & 1 deletion src/path.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { existsSync } from 'node:fs'
import path from 'node:path'
import vscode from 'vscode'
import { name as bakExt } from './generated/meta'
Expand Down Expand Up @@ -60,13 +61,14 @@ export const rendererBakPath = getRendererPath('js', bakExt)

function getMainPath(baseExt: string, backupExt?: string) {
const ext = backupExt ? `${backupExt}.${baseExt}` : baseExt
return path.join(
const defaultPath = path.join(
baseDir,
'vs',
'code',
'electron-main',
`main.${ext}`,
)
return existsSync(defaultPath) ? defaultPath : path.join(baseDir, `main.${ext}`)
}

export const mainPath = getMainPath('js')
Expand Down

0 comments on commit 0bb433d

Please sign in to comment.