gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: better default config locatio


From: gnunet
Subject: [taler-wallet-core] branch master updated: better default config location detection
Date: Wed, 04 Aug 2021 12:21:11 +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 f92cbdbf better default config location detection
f92cbdbf is described below

commit f92cbdbf476d4b51e1315ae26679008ae6889f60
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Aug 4 12:21:05 2021 +0200

    better default config location detection
---
 packages/taler-util/src/talerconfig.ts             | 30 ++++++++++++++++++++++
 .../src/integrationtests/test-libeufin-tutorial.ts |  1 -
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/packages/taler-util/src/talerconfig.ts 
b/packages/taler-util/src/talerconfig.ts
index 624d4ff3..ebc41885 100644
--- a/packages/taler-util/src/talerconfig.ts
+++ b/packages/taler-util/src/talerconfig.ts
@@ -294,6 +294,26 @@ function normalizeInlineFilename(parentFile: string, f: 
string): string {
   return nodejs_path().join(resolvedParentDir, f);
 }
 
+/**
+ * Crude implementation of the which(1) shell command.
+ * 
+ * Tries to locate the location of an executable based on the
+ * "PATH" environment variable.
+ */
+function which(name: string): string | undefined {
+  const paths = process.env["PATH"]?.split(":");
+  if (!paths) {
+    return undefined;
+  }
+  for (const path of paths) {
+    const filename = nodejs_path().join(path, name);
+    if (nodejs_fs().existsSync(filename)) {
+      return filename;
+    }
+  }
+  return undefined;
+}
+
 export class Configuration {
   private sectionMap: SectionMap = {};
 
@@ -613,6 +633,16 @@ export class Configuration {
 
   private loadDefaults(): void {
     let bc = process.env["TALER_BASE_CONFIG"];
+    if (!bc) {
+      /* Try to locate the configuration based on the location
+       * of the taler-config binary. */
+      const path = which("taler-config");
+      if (path) {
+        bc = nodejs_fs().realpathSync(
+          nodejs_path().dirname(path) + "/../share/taler/config.d",
+        );
+      }
+    }
     if (!bc) {
       bc = "/usr/share/taler/config.d";
     }
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts
index 59c9b28a..707a264f 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-libeufin-tutorial.ts
@@ -124,7 +124,6 @@ export async function runLibeufinTutorialTest(t: 
GlobalTestState) {
     currency: "EUR",
     facadeName: "my-twg",
   });
-
   await libeufinCli.listFacades();
 }
 runLibeufinTutorialTest.suites = ["libeufin"];

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]