mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
added possibility to set config file path in environment file
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as yaml from 'js-yaml'
|
||||
import { app } from 'electron'
|
||||
import { writeFile } from 'atomically'
|
||||
|
||||
|
||||
export const configPath = path.join(process.env.CONFIG_DIRECTORY!, 'config.yaml')
|
||||
const legacyConfigPath = path.join(process.env.CONFIG_DIRECTORY!, '../terminus', 'config.yaml')
|
||||
|
||||
|
||||
export function migrateConfig (): void {
|
||||
const configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||
const legacyConfigPath = path.join(app.getPath('userData'), '../terminus', 'config.yaml')
|
||||
if (fs.existsSync(legacyConfigPath) && (
|
||||
!fs.existsSync(configPath) ||
|
||||
fs.statSync(configPath).mtime < fs.statSync(legacyConfigPath).mtime
|
||||
@@ -19,7 +20,6 @@ export function migrateConfig (): void {
|
||||
export function loadConfig (): any {
|
||||
migrateConfig()
|
||||
|
||||
const configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||
if (fs.existsSync(configPath)) {
|
||||
return yaml.load(fs.readFileSync(configPath, 'utf8'))
|
||||
} else {
|
||||
@@ -27,9 +27,7 @@ export function loadConfig (): any {
|
||||
}
|
||||
}
|
||||
|
||||
const configPath = path.join(app.getPath('userData'), 'config.yaml')
|
||||
|
||||
export async function saveConfig (content: string): Promise<void> {
|
||||
await writeFile(configPath, content, { encoding: 'utf8' })
|
||||
await writeFile(configPath + '.backup', content, { encoding: 'utf8' })
|
||||
}
|
||||
}
|
@@ -1,17 +1,21 @@
|
||||
import { app, ipcMain, Menu, dialog } from 'electron'
|
||||
|
||||
// set defaults of environment variables
|
||||
import 'dotenv/config'
|
||||
process.env.TABBY_PLUGINS ??= ''
|
||||
process.env.CONFIG_DIRECTORY ??= app.getPath('userData')
|
||||
|
||||
|
||||
import 'v8-compile-cache'
|
||||
import './portable'
|
||||
import 'source-map-support/register'
|
||||
import './sentry'
|
||||
import './lru'
|
||||
import { app, ipcMain, Menu, dialog } from 'electron'
|
||||
import { parseArgs } from './cli'
|
||||
import { Application } from './app'
|
||||
import electronDebug = require('electron-debug')
|
||||
import { loadConfig } from './config'
|
||||
|
||||
if (!process.env.TABBY_PLUGINS) {
|
||||
process.env.TABBY_PLUGINS = ''
|
||||
}
|
||||
|
||||
const argv = parseArgs(process.argv, process.cwd())
|
||||
|
||||
|
Reference in New Issue
Block a user