[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: taler-util: make config parsi
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: taler-util: make config parsing more compliant with spec |
Date: |
Fri, 25 Aug 2023 14:11:39 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new c95740f1e taler-util: make config parsing more compliant with spec
c95740f1e is described below
commit c95740f1e845d1bb14b5e255b1d217dd30b3a7da
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Aug 25 14:11:23 2023 +0200
taler-util: make config parsing more compliant with spec
---
packages/taler-harness/src/lint.ts | 4 ++--
packages/taler-util/src/talerconfig.ts | 36 +++++++++++++++++++++++++++-------
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/packages/taler-harness/src/lint.ts
b/packages/taler-harness/src/lint.ts
index 715227c7f..f13049710 100644
--- a/packages/taler-harness/src/lint.ts
+++ b/packages/taler-harness/src/lint.ts
@@ -136,13 +136,13 @@ function checkBasicConf(context: LintContext): BasicConf {
const currencyEntry = cfg.getString("taler", "currency");
let mainCurrency: string | undefined;
- if (!currencyEntry.value) {
+ if (!currencyEntry.isDefined()) {
context.numErr++;
console.log("error: currency not defined in section TALER option
CURRENCY");
console.log("Aborting further checks.");
process.exit(1);
} else {
- mainCurrency = currencyEntry.value.toUpperCase();
+ mainCurrency = currencyEntry.required().toUpperCase();
}
if (mainCurrency === "KUDOS") {
diff --git a/packages/taler-util/src/talerconfig.ts
b/packages/taler-util/src/talerconfig.ts
index d86c58678..098f5f9a4 100644
--- a/packages/taler-util/src/talerconfig.ts
+++ b/packages/taler-util/src/talerconfig.ts
@@ -25,11 +25,14 @@
*/
import { AmountJson } from "./amounts.js";
import { Amounts } from "./amounts.js";
+import { Logger } from "./logging.js";
import nodejs_path from "path";
import nodejs_os from "os";
import nodejs_fs from "fs";
+const logger = new Logger("talerconfig.ts");
+
export class ConfigError extends Error {
constructor(message: string) {
super();
@@ -77,7 +80,7 @@ export class ConfigValue<T> {
constructor(
private sectionName: string,
private optionName: string,
- public value: string | undefined,
+ private value: string | undefined,
private converter: (x: string) => T,
) {}
@@ -138,7 +141,7 @@ export function pathsub(
lookup: (s: string, depth: number) => string | undefined,
depth = 0,
): string {
- if (depth >= 10) {
+ if (depth >= 128) {
throw Error("recursion in path substitution");
}
let s = x;
@@ -624,15 +627,18 @@ export class Configuration {
lookupVariable(x: string, depth: number = 0): string | undefined {
// We loop up options in PATHS in upper case, as option names
// are case insensitive
- let val = this.findEntry("PATHS", x)?.value;
+ const val = this.findEntry("PATHS", x)?.value;
if (val !== undefined) {
return pathsub(val, (v, d) => this.lookupVariable(v, d), depth);
}
+
// Environment variables can be case sensitive, respect that.
const envVal = process.env[x];
if (envVal !== undefined) {
return envVal;
}
+
+ logger.warn(`unable to resolve variable '${x}'`);
return;
}
@@ -692,12 +698,28 @@ export class Configuration {
"DOCDIR",
`${installPrefix}/share/doc/taler/`,
);
- this.setStringSystemDefault("PATHS", "ICONDIR",
`${installPrefix}/share/icons/`);
- this.setStringSystemDefault("PATHS", "LOCALEDIR",
`${installPrefix}/share/locale/`);
+ this.setStringSystemDefault(
+ "PATHS",
+ "ICONDIR",
+ `${installPrefix}/share/icons/`,
+ );
+ this.setStringSystemDefault(
+ "PATHS",
+ "LOCALEDIR",
+ `${installPrefix}/share/locale/`,
+ );
this.setStringSystemDefault("PATHS", "PREFIX", `${installPrefix}/`);
this.setStringSystemDefault("PATHS", "BINDIR", `${installPrefix}/bin`);
- this.setStringSystemDefault("PATHS", "LIBDIR",
`${installPrefix}/lib/taler/`);
- this.setStringSystemDefault("PATHS", "DATADIR",
`${installPrefix}/share/taler/`);
+ this.setStringSystemDefault(
+ "PATHS",
+ "LIBDIR",
+ `${installPrefix}/lib/taler/`,
+ );
+ this.setStringSystemDefault(
+ "PATHS",
+ "DATADIR",
+ `${installPrefix}/share/taler/`,
+ );
this.loadDefaultsFromDir(baseConfigDir);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: taler-util: make config parsing more compliant with spec,
gnunet <=