From 5d1968b91f2ebadb4f15a1fa66ae1180e08342a2 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Thu, 5 Dec 2024 00:03:16 -0500 Subject: [PATCH] chore: `flags` supports mutli option --- multichain-testing/tools/agd-lib.js | 9 +++++++-- multichain-testing/tools/deploy.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/multichain-testing/tools/agd-lib.js b/multichain-testing/tools/agd-lib.js index a28d408493b..71ed0f69cbd 100644 --- a/multichain-testing/tools/agd-lib.js +++ b/multichain-testing/tools/agd-lib.js @@ -16,7 +16,7 @@ const binaryArgs = [ ]; /** - * @param {Record} record - e.g. { color: 'blue' } + * @param {Record} record - e.g. { color: 'blue' } * @returns {string[]} - e.g. ['--color', 'blue'] */ export const flags = record => { @@ -25,7 +25,12 @@ export const flags = record => { /** @type {[string, string][]} */ // @ts-expect-error undefined is filtered out const skipUndef = Object.entries(record).filter(([_k, v]) => v !== undefined); - return skipUndef.map(([k, v]) => [`--${k}`, v]).flat(); + return skipUndef.flatMap(([key, value]) => { + if (Array.isArray(value)) { + return value.flatMap(v => [`--${key}`, v]); + } + return [`--${key}`, value]; + }); }; /** diff --git a/multichain-testing/tools/deploy.ts b/multichain-testing/tools/deploy.ts index 52a460f6094..289c4d971e9 100755 --- a/multichain-testing/tools/deploy.ts +++ b/multichain-testing/tools/deploy.ts @@ -13,7 +13,7 @@ export const makeDeployBuilder = ( ) => async function deployBuilder( builder: string, - builderOpts?: Record, + builderOpts?: Record, ) { console.log(`building plan: ${builder}`); const args = ['run', builder];