Skip to content

Commit

Permalink
chore: flags supports mutli option
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Dec 10, 2024
1 parent ba64f7a commit 5d1968b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions multichain-testing/tools/agd-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const binaryArgs = [
];

/**
* @param {Record<string, string | undefined>} record - e.g. { color: 'blue' }
* @param {Record<string, string | string[] | undefined>} record - e.g. { color: 'blue' }
* @returns {string[]} - e.g. ['--color', 'blue']
*/
export const flags = record => {
Expand All @@ -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];
});
};

/**
Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/tools/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const makeDeployBuilder = (
) =>
async function deployBuilder(
builder: string,
builderOpts?: Record<string, string>,
builderOpts?: Record<string, string | string[]>,
) {
console.log(`building plan: ${builder}`);
const args = ['run', builder];
Expand Down

0 comments on commit 5d1968b

Please sign in to comment.