Allow user-data-dir and extension-dir in config.yaml

Closes #1676
This commit is contained in:
Anmol Sethi
2020-05-19 00:39:57 -04:00
parent aa87270148
commit 8053ec6872
3 changed files with 58 additions and 52 deletions

View File

@@ -152,12 +152,12 @@ export const optionDescriptions = (): string[] => {
)
}
export const parse = async (
export const parse = (
argv: string[],
opts?: {
configFile: string
},
): Promise<Args> => {
): Args => {
const error = (msg: string): Error => {
if (opts?.configFile) {
msg = `error reading ${opts.configFile}: ${msg}`
@@ -288,18 +288,28 @@ export const parse = async (
break
case LogLevel.Debug:
logger.level = Level.Debug
args.verbose = false
break
case LogLevel.Info:
logger.level = Level.Info
args.verbose = false
break
case LogLevel.Warn:
logger.level = Level.Warning
args.verbose = false
break
case LogLevel.Error:
logger.level = Level.Error
args.verbose = false
break
}
return args
}
export async function setDefaults(args: Args): Promise<Args> {
args = { ...args }
if (!args["user-data-dir"]) {
await copyOldMacOSDataDir()
args["user-data-dir"] = paths.data
@@ -353,7 +363,7 @@ export async function readConfigFile(configPath?: string): Promise<Args> {
}
return `--${optName}=${opt}`
})
const args = await parse(configFileArgv, {
const args = parse(configFileArgv, {
configFile: configPath,
})
return {