Skip to content

Commit 27c3650

Browse files
filipesilvavikerman
authored andcommitted
feat(@angular-devkit/architect): support multiple configs in WorkspaceNodeModulesArchitectHost
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.
1 parent a7f977f commit 27c3650

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/angular_devkit/architect/node/node-modules-architect-host.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,26 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
100100
if (targetSpec === undefined) {
101101
return null;
102102
}
103-
if (
104-
target.configuration
105-
&& !(targetSpec['configurations'] && targetSpec['configurations'][target.configuration])
106-
) {
107-
throw new Error(`Configuration '${target.configuration}' is not set in the workspace.`);
103+
104+
let additionalOptions = {};
105+
106+
if (target.configuration) {
107+
const configurations = target.configuration.split(',').map(c => c.trim());
108+
for (const configuration of configurations) {
109+
if (!(targetSpec['configurations'] && targetSpec['configurations'][configuration])) {
110+
throw new Error(`Configuration '${configuration}' is not set in the workspace.`);
111+
} else {
112+
additionalOptions = {
113+
...additionalOptions,
114+
...targetSpec['configurations'][configuration],
115+
};
116+
}
117+
}
108118
}
109119

110120
return {
111121
...targetSpec['options'],
112-
...(target.configuration ? targetSpec['configurations'][target.configuration] : 0),
122+
...additionalOptions,
113123
};
114124
}
115125

0 commit comments

Comments
 (0)