Merge branch 'master' into age-withdraw

This commit is contained in:
Özgür Kesim 2023-08-28 14:46:20 +02:00
commit fe7b4c8c0c
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
2 changed files with 31 additions and 9 deletions

View File

@ -136,13 +136,13 @@ function checkBasicConf(context: LintContext): BasicConf {
const currencyEntry = cfg.getString("taler", "currency"); const currencyEntry = cfg.getString("taler", "currency");
let mainCurrency: string | undefined; let mainCurrency: string | undefined;
if (!currencyEntry.value) { if (!currencyEntry.isDefined()) {
context.numErr++; context.numErr++;
console.log("error: currency not defined in section TALER option CURRENCY"); console.log("error: currency not defined in section TALER option CURRENCY");
console.log("Aborting further checks."); console.log("Aborting further checks.");
process.exit(1); process.exit(1);
} else { } else {
mainCurrency = currencyEntry.value.toUpperCase(); mainCurrency = currencyEntry.required().toUpperCase();
} }
if (mainCurrency === "KUDOS") { if (mainCurrency === "KUDOS") {

View File

@ -25,11 +25,14 @@
*/ */
import { AmountJson } from "./amounts.js"; import { AmountJson } from "./amounts.js";
import { Amounts } from "./amounts.js"; import { Amounts } from "./amounts.js";
import { Logger } from "./logging.js";
import nodejs_path from "path"; import nodejs_path from "path";
import nodejs_os from "os"; import nodejs_os from "os";
import nodejs_fs from "fs"; import nodejs_fs from "fs";
const logger = new Logger("talerconfig.ts");
export class ConfigError extends Error { export class ConfigError extends Error {
constructor(message: string) { constructor(message: string) {
super(); super();
@ -77,7 +80,7 @@ export class ConfigValue<T> {
constructor( constructor(
private sectionName: string, private sectionName: string,
private optionName: string, private optionName: string,
public value: string | undefined, private value: string | undefined,
private converter: (x: string) => T, private converter: (x: string) => T,
) {} ) {}
@ -138,7 +141,7 @@ export function pathsub(
lookup: (s: string, depth: number) => string | undefined, lookup: (s: string, depth: number) => string | undefined,
depth = 0, depth = 0,
): string { ): string {
if (depth >= 10) { if (depth >= 128) {
throw Error("recursion in path substitution"); throw Error("recursion in path substitution");
} }
let s = x; let s = x;
@ -624,15 +627,18 @@ export class Configuration {
lookupVariable(x: string, depth: number = 0): string | undefined { lookupVariable(x: string, depth: number = 0): string | undefined {
// We loop up options in PATHS in upper case, as option names // We loop up options in PATHS in upper case, as option names
// are case insensitive // are case insensitive
let val = this.findEntry("PATHS", x)?.value; const val = this.findEntry("PATHS", x)?.value;
if (val !== undefined) { if (val !== undefined) {
return pathsub(val, (v, d) => this.lookupVariable(v, d), depth); return pathsub(val, (v, d) => this.lookupVariable(v, d), depth);
} }
// Environment variables can be case sensitive, respect that. // Environment variables can be case sensitive, respect that.
const envVal = process.env[x]; const envVal = process.env[x];
if (envVal !== undefined) { if (envVal !== undefined) {
return envVal; return envVal;
} }
logger.warn(`unable to resolve variable '${x}'`);
return; return;
} }
@ -692,12 +698,28 @@ export class Configuration {
"DOCDIR", "DOCDIR",
`${installPrefix}/share/doc/taler/`, `${installPrefix}/share/doc/taler/`,
); );
this.setStringSystemDefault("PATHS", "ICONDIR", `${installPrefix}/share/icons/`); this.setStringSystemDefault(
this.setStringSystemDefault("PATHS", "LOCALEDIR", `${installPrefix}/share/locale/`); "PATHS",
"ICONDIR",
`${installPrefix}/share/icons/`,
);
this.setStringSystemDefault(
"PATHS",
"LOCALEDIR",
`${installPrefix}/share/locale/`,
);
this.setStringSystemDefault("PATHS", "PREFIX", `${installPrefix}/`); this.setStringSystemDefault("PATHS", "PREFIX", `${installPrefix}/`);
this.setStringSystemDefault("PATHS", "BINDIR", `${installPrefix}/bin`); this.setStringSystemDefault("PATHS", "BINDIR", `${installPrefix}/bin`);
this.setStringSystemDefault("PATHS", "LIBDIR", `${installPrefix}/lib/taler/`); this.setStringSystemDefault(
this.setStringSystemDefault("PATHS", "DATADIR", `${installPrefix}/share/taler/`); "PATHS",
"LIBDIR",
`${installPrefix}/lib/taler/`,
);
this.setStringSystemDefault(
"PATHS",
"DATADIR",
`${installPrefix}/share/taler/`,
);
this.loadDefaultsFromDir(baseConfigDir); this.loadDefaultsFromDir(baseConfigDir);
} }