From aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 30 Mar 2020 16:09:32 +0530 Subject: re-format with prettier v2, fix HTML --- src/headless/NodeHttpLib.ts | 14 ++++++++------ src/headless/clk.ts | 26 ++++++++++++++------------ src/headless/helpers.ts | 6 ++++-- src/headless/integrationtest.ts | 11 ++++++++--- src/headless/merchant.ts | 7 +++++-- 5 files changed, 39 insertions(+), 25 deletions(-) (limited to 'src/headless') diff --git a/src/headless/NodeHttpLib.ts b/src/headless/NodeHttpLib.ts index 5cbb40ccf..735d6b3cf 100644 --- a/src/headless/NodeHttpLib.ts +++ b/src/headless/NodeHttpLib.ts @@ -16,7 +16,12 @@ SPDX-License-Identifier: AGPL3.0-or-later */ -import { Headers, HttpRequestLibrary, HttpRequestOptions, HttpResponse } from "../util/http"; +import { + Headers, + HttpRequestLibrary, + HttpRequestOptions, + HttpResponse, +} from "../util/http"; import { RequestThrottler } from "../util/RequestThrottler"; import Axios, { AxiosResponse } from "axios"; @@ -85,10 +90,7 @@ export class NodeHttpLib implements HttpRequestLibrary { }; } - async get( - url: string, - opt?: HttpRequestOptions, - ): Promise { + async get(url: string, opt?: HttpRequestOptions): Promise { return this.req("get", url, undefined, opt); } @@ -99,4 +101,4 @@ export class NodeHttpLib implements HttpRequestLibrary { ): Promise { return this.req("post", url, body, opt); } -} \ No newline at end of file +} diff --git a/src/headless/clk.ts b/src/headless/clk.ts index ab6526f9c..7d7417ea9 100644 --- a/src/headless/clk.ts +++ b/src/headless/clk.ts @@ -340,7 +340,9 @@ export class CommandGroup { const r = splitOpt(opt); const d = this.longOptions[r.key]; if (!d) { - console.error(`error: unknown option '--${r.key}' for ${currentName}`); + console.error( + `error: unknown option '--${r.key}' for ${currentName}`, + ); process.exit(-1); throw Error("not reached"); } @@ -359,7 +361,7 @@ export class CommandGroup { process.exit(-1); throw Error("not reached"); } - myArgs[d.name] = unparsedArgs[i+1]; + myArgs[d.name] = unparsedArgs[i + 1]; i++; } else { myArgs[d.name] = r.value; @@ -427,14 +429,15 @@ export class CommandGroup { throw Error("not reached"); } - for (let i = posArgIndex; i < this.arguments.length; i++) { const d = this.arguments[i]; if (d.required) { if (d.args.default !== undefined) { myArgs[d.name] = d.args.default; } else { - console.error(`error: missing positional argument '${d.name}' for ${currentName}`); + console.error( + `error: missing positional argument '${d.name}' for ${currentName}`, + ); process.exit(-1); throw Error("not reached"); } @@ -447,7 +450,7 @@ export class CommandGroup { if (option.args.default !== undefined) { myArgs[option.name] = option.args.default; } else { - const name = option.flagspec.join(",") + const name = option.flagspec.join(","); console.error(`error: missing option '${name}'`); process.exit(-1); throw Error("not reached"); @@ -584,10 +587,11 @@ export class Program { } } -export type GetArgType = - T extends Program ? AT : - T extends CommandGroup ? AT : - any; +export type GetArgType = T extends Program + ? AT + : T extends CommandGroup + ? AT + : any; export function program( argKey: PN, @@ -596,15 +600,13 @@ export function program( return new Program(argKey as string, args); } - - export function prompt(question: string): Promise { const stdinReadline = readline.createInterface({ input: process.stdin, output: process.stdout, }); return new Promise((resolve, reject) => { - stdinReadline.question(question, res => { + stdinReadline.question(question, (res) => { resolve(res); stdinReadline.close(); }); diff --git a/src/headless/helpers.ts b/src/headless/helpers.ts index dc56a9876..fb3d800d4 100644 --- a/src/headless/helpers.ts +++ b/src/headless/helpers.ts @@ -120,7 +120,9 @@ export async function getDefaultNodeWallet( require("worker_threads"); workerFactory = new NodeThreadCryptoWorkerFactory(); } catch (e) { - console.log("worker threads not available, falling back to synchronous workers"); + console.log( + "worker threads not available, falling back to synchronous workers", + ); workerFactory = new SynchronousCryptoWorkerFactory(); } @@ -161,7 +163,7 @@ export async function withdrawTestBalance( myWallet.runRetryLoop().catch((x) => { reject(x); }); - myWallet.addNotificationListener(n => { + myWallet.addNotificationListener((n) => { if ( n.type === NotificationType.ReserveDepleted && n.reservePub === reservePub diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts index 0c015207e..191e48ff6 100644 --- a/src/headless/integrationtest.ts +++ b/src/headless/integrationtest.ts @@ -99,7 +99,7 @@ export async function runIntegrationTest(args: IntegrationTestArgs) { const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib }); - myWallet.runRetryLoop().catch(e => { + myWallet.runRetryLoop().catch((e) => { console.error("exception during retry loop:", e); }); @@ -233,7 +233,7 @@ export async function runIntegrationTestBasic(cfg: Configuration) { persistentStoragePath: walletDbPath, }); - myWallet.runRetryLoop().catch(e => { + myWallet.runRetryLoop().catch((e) => { console.error("exception during retry loop:", e); }); @@ -255,7 +255,12 @@ export async function runIntegrationTestBasic(cfg: Configuration) { merchantApiKey, ); - await makePayment(myWallet, myMerchant, Amounts.toString(parsedSpendAmount), "hello world"); + await makePayment( + myWallet, + myMerchant, + Amounts.toString(parsedSpendAmount), + "hello world", + ); // Wait until the refresh is done await myWallet.runUntilDone(); diff --git a/src/headless/merchant.ts b/src/headless/merchant.ts index b30e00d8a..27e7e3f21 100644 --- a/src/headless/merchant.ts +++ b/src/headless/merchant.ts @@ -23,7 +23,10 @@ * Imports. */ import axios from "axios"; -import { CheckPaymentResponse, codecForCheckPaymentResponse } from "../types/talerTypes"; +import { + CheckPaymentResponse, + codecForCheckPaymentResponse, +} from "../types/talerTypes"; /** * Connection to the *internal* merchant backend. @@ -133,7 +136,7 @@ export class MerchantBackendConnection { if (resp.status != 200) { throw Error("failed to check payment"); } - + return codecForCheckPaymentResponse().decode(resp.data); } } -- cgit v1.2.3