This commit is contained in:
Izuco 2022-03-17 17:26:43 +01:00
parent 431e840913
commit 9a805f995a
No known key found for this signature in database
GPG key ID: E9CBE9E4EF3A1BFA
3 changed files with 45 additions and 2 deletions

View file

@ -5,7 +5,7 @@ import dotenv from 'dotenv';
import express from 'express';
import { Console } from 'console';
import json from '../../../package.json';
import { ensureConfig } from '../../../modules/module.cfg-loader';
process.on('uncaughtException', (er, or) => {
console.error(er, or);
@ -50,7 +50,7 @@ if (!fs.existsSync(getDataDirectory()))
export { getDataDirectory };
process.env.contentDirectory = getDataDirectory();
ensureConfig();
import './menu';

View file

@ -44,6 +44,41 @@ const template: (MenuItemConstructorOptions | MenuItem)[] = [
}
]
},
{
label: 'Settings',
submenu: [
{
label: 'Open settings folder',
click: () => {
shell.openPath(path.join(getDataDirectory(), 'config'))
}
},
{
label: 'Open settings file...',
submenu: [
{
label: 'FFmpeg/Mkvmerge path',
click: () => {
shell.openPath(path.join(getDataDirectory(), 'config', 'bin-path.yml'))
}
},
{
label: 'Advanced options',
sublabel: 'See the documention for the options you may enter here',
click: () => {
shell.openPath(path.join(getDataDirectory(), 'config', 'cli-defaults.yml'))
}
},
{
label: 'Output path',
click: () => {
shell.openPath(path.join(getDataDirectory(), 'config', 'dir-path.yml'))
}
}
]
}
]
},
{
label: 'Help',
submenu: [

View file

@ -19,6 +19,14 @@ const tokenFile = {
cr: path.join(workingDir, 'config', 'cr_token')
};
export const ensureConfig = () => {
if (process.env.contentDirectory)
[binCfgFile, dirCfgFile, cliCfgFile].forEach(a => {
if (!fs.existsSync(`${a}.yml`))
fs.copyFileSync(path.join('config', `${path.basename(a)}.yml`), `${a}.yml`);
})
}
const loadYamlCfgFile = <T extends Record<string, any>>(file: string, isSess?: boolean): T => {
if(fs.existsSync(`${file}.user.yml`) && !isSess){
file += '.user';