Skip to content

Commit

Permalink
feat(@angular-devkit/architect): support multiple configs in Workspac…
Browse files Browse the repository at this point in the history
…eNodeModulesArchitectHost

Add support for parsing multiple configurations in a single string using comma as a separator.

This support is only at the host level (`WorkspaceNodeModulesArchitectHost` in this case) and does not change the underlying Architect API.

Different hosts are able to compose target options in different ways.
  • Loading branch information
filipesilva authored and vikerman committed Oct 14, 2019
1 parent a7f977f commit 27c3650
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,26 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
if (targetSpec === undefined) {
return null;
}
if (
target.configuration
&& !(targetSpec['configurations'] && targetSpec['configurations'][target.configuration])
) {
throw new Error(`Configuration '${target.configuration}' is not set in the workspace.`);

let additionalOptions = {};

if (target.configuration) {
const configurations = target.configuration.split(',').map(c => c.trim());
for (const configuration of configurations) {
if (!(targetSpec['configurations'] && targetSpec['configurations'][configuration])) {
throw new Error(`Configuration '${configuration}' is not set in the workspace.`);
} else {
additionalOptions = {
...additionalOptions,
...targetSpec['configurations'][configuration],
};
}
}
}

return {
...targetSpec['options'],
...(target.configuration ? targetSpec['configurations'][target.configuration] : 0),
...additionalOptions,
};
}

Expand Down

0 comments on commit 27c3650

Please sign in to comment.