summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-10-31 00:07:37 -0300
committerSebastian <sebasjm@gmail.com>2022-10-31 00:07:54 -0300
commit2f17d818023677f4cba6facdc1262249d0b7569b (patch)
tree881bd2c09c65583973e397de7c09333374e39579 /packages/taler-wallet-cli
parent4feb79f3c92f7f1c5d3fd66b207d77b144f1c1d0 (diff)
downloadwallet-core-2f17d818023677f4cba6facdc1262249d0b7569b.tar.gz
wallet-core-2f17d818023677f4cba6facdc1262249d0b7569b.tar.bz2
wallet-core-2f17d818023677f4cba6facdc1262249d0b7569b.zip
require and __filename is not supported for ESM
Diffstat (limited to 'packages/taler-wallet-cli')
-rwxr-xr-xpackages/taler-wallet-cli/bin/taler-wallet-cli7
-rwxr-xr-xpackages/taler-wallet-cli/bin/taler-wallet-cli.js15
-rw-r--r--packages/taler-wallet-cli/package.json2
-rw-r--r--packages/taler-wallet-cli/src/assets.ts6
-rw-r--r--packages/taler-wallet-cli/src/harness/harness.ts20
-rw-r--r--packages/taler-wallet-cli/src/harness/sync.ts5
6 files changed, 32 insertions, 23 deletions
diff --git a/packages/taler-wallet-cli/bin/taler-wallet-cli b/packages/taler-wallet-cli/bin/taler-wallet-cli
deleted file mode 100755
index ca8008e30..000000000
--- a/packages/taler-wallet-cli/bin/taler-wallet-cli
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env node
-try {
- require('source-map-support').install();
-} catch (e) {
- // Do nothing.
-}
-require('../dist/taler-wallet-cli.js').main();
diff --git a/packages/taler-wallet-cli/bin/taler-wallet-cli.js b/packages/taler-wallet-cli/bin/taler-wallet-cli.js
new file mode 100755
index 000000000..bcec228e6
--- /dev/null
+++ b/packages/taler-wallet-cli/bin/taler-wallet-cli.js
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+
+import { main } from '../lib/index.js';
+
+async function run() {
+ try {
+ (await import('source-map-support')).install();
+ } catch (e) {
+ // Do nothing.
+ }
+ main();
+}
+
+run();
+
diff --git a/packages/taler-wallet-cli/package.json b/packages/taler-wallet-cli/package.json
index ac1ff4ef5..7c2cc007d 100644
--- a/packages/taler-wallet-cli/package.json
+++ b/packages/taler-wallet-cli/package.json
@@ -13,7 +13,7 @@
"license": "GPL-3.0",
"main": "dist/taler-wallet-cli.js",
"bin": {
- "taler-wallet-cli": "./bin/taler-wallet-cli"
+ "taler-wallet-cli": "./bin/taler-wallet-cli.js"
},
"type": "module",
"scripts": {
diff --git a/packages/taler-wallet-cli/src/assets.ts b/packages/taler-wallet-cli/src/assets.ts
index 72fc9fe04..8e9306780 100644
--- a/packages/taler-wallet-cli/src/assets.ts
+++ b/packages/taler-wallet-cli/src/assets.ts
@@ -20,6 +20,8 @@
import path from "path";
import fs from "fs";
+const assetFileUrl = import.meta.url;
+
/**
* Resolve an asset name into an absolute filename.
*
@@ -27,8 +29,8 @@ import fs from "fs";
* at the top level of the package (i.e. next to package.json).
*/
export function resolveAsset(name: string): string {
- const n = __filename;
- const d = __dirname;
+ const n = path.basename(assetFileUrl);
+ const d = path.dirname(assetFileUrl);
let assetPath: string;
// Currently both asset paths are the same.
// This might change if the file that contains "resolveAsset"
diff --git a/packages/taler-wallet-cli/src/harness/harness.ts b/packages/taler-wallet-cli/src/harness/harness.ts
index ae2845655..26ced4334 100644
--- a/packages/taler-wallet-cli/src/harness/harness.ts
+++ b/packages/taler-wallet-cli/src/harness/harness.ts
@@ -57,6 +57,7 @@ import {
import { deepStrictEqual } from "assert";
import axiosImp, { AxiosError } from "axios";
import { ChildProcess, spawn } from "child_process";
+import * as child_process from "child_process";
import * as fs from "fs";
import * as http from "http";
import * as path from "path";
@@ -77,7 +78,7 @@ import {
TippingReserveStatus,
} from "./merchantApiTypes.js";
-const exec = util.promisify(require("child_process").exec);
+const exec = util.promisify(child_process.exec);
const axios = axiosImp.default;
@@ -485,7 +486,7 @@ class BankServiceBase {
protected globalTestState: GlobalTestState,
protected bankConfig: BankConfig,
protected configFile: string,
- ) {}
+ ) { }
}
/**
@@ -779,8 +780,7 @@ class LibEuFinBankService extends BankServiceBase implements BankServiceHandle {
*/
export class FakebankService
extends BankServiceBase
- implements BankServiceHandle
-{
+ implements BankServiceHandle {
proc: ProcessWrapper | undefined;
http = new NodeHttpLib();
@@ -1131,7 +1131,7 @@ export class ExchangeService implements ExchangeServiceInterface {
private exchangeConfig: ExchangeConfig,
private configFilename: string,
private keyPair: EddsaKeyPair,
- ) {}
+ ) { }
get name() {
return this.exchangeConfig.name;
@@ -1384,7 +1384,7 @@ export class MerchantApiClient {
constructor(
private baseUrl: string,
public readonly auth: MerchantAuthConfiguration,
- ) {}
+ ) { }
async changeAuth(auth: MerchantAuthConfiguration): Promise<void> {
const url = new URL("private/auth", this.baseUrl);
@@ -1577,7 +1577,7 @@ export class MerchantService implements MerchantServiceInterface {
private globalState: GlobalTestState,
private merchantConfig: MerchantConfig,
private configFilename: string,
- ) {}
+ ) { }
private currentTimetravel: Duration | undefined;
@@ -1899,10 +1899,8 @@ export class WalletCli {
const resp = await sh(
self.globalTestState,
`wallet-${self.name}`,
- `taler-wallet-cli ${
- self.timetravelArg ?? ""
- } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${
- self.dbfile
+ `taler-wallet-cli ${self.timetravelArg ?? ""
+ } ${cryptoWorkerArg} --no-throttle -LTRACE --skip-defaults --wallet-db '${self.dbfile
}' api '${op}' ${shellWrap(JSON.stringify(payload))}`,
);
logger.info("--- wallet core response ---");
diff --git a/packages/taler-wallet-cli/src/harness/sync.ts b/packages/taler-wallet-cli/src/harness/sync.ts
index 16be89eff..a9e8de412 100644
--- a/packages/taler-wallet-cli/src/harness/sync.ts
+++ b/packages/taler-wallet-cli/src/harness/sync.ts
@@ -26,8 +26,9 @@ import {
ProcessWrapper,
} from "../harness/harness.js";
import { Configuration } from "@gnu-taler/taler-util";
+import * as child_process from "child_process";
-const exec = util.promisify(require("child_process").exec);
+const exec = util.promisify(child_process.exec);
export interface SyncConfig {
/**
@@ -114,5 +115,5 @@ export class SyncService {
private globalState: GlobalTestState,
private syncConfig: SyncConfig,
private configFilename: string,
- ) {}
+ ) { }
}