Skip to content

Commit

Permalink
Improved inputs' reusability
Browse files Browse the repository at this point in the history
  • Loading branch information
yvann committed Feb 4, 2025
1 parent 8d595a6 commit a25c383
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,18 @@ export class VirtualOutputType<
);
const argsConfigPath = utils.addPath(this.configPath, 'args');

utils.assertNillablePlainObject(argsConfig, argsConfigPath);

if (argsConfig) {
const inputs: utils.Input[] = [];

if (Array.isArray(argsConfig)) {
inputs.push(...argsConfig);
} else {
for (const [name, config] of Object.entries(argsConfig)) {
if (config) {
const configPath = utils.addPath(argsConfigPath, name);

inputs.push(new utils.Input({ name, ...config }, configPath));
}
}
}
const inputs: utils.Input[] = Array.isArray(argsConfig)
? argsConfig
: Object.entries(utils.ensurePlainObject(argsConfig, argsConfigPath))
.filter(([, config]) => config)
.map(
([name, config]) =>
new utils.Input(
{ name, ...config },
utils.addPath(argsConfigPath, name),
),
);

return inputs.length ? inputs : undefined;
}
Expand Down

0 comments on commit a25c383

Please # to comment.