@@ -11,7 +11,14 @@ import {
11
11
BuilderDescription ,
12
12
TargetSpecifier ,
13
13
} from '@angular-devkit/architect' ;
14
- import { JsonObject , UnknownException , experimental , schema , strings } from '@angular-devkit/core' ;
14
+ import {
15
+ JsonObject ,
16
+ UnknownException ,
17
+ experimental ,
18
+ schema ,
19
+ strings ,
20
+ tags ,
21
+ } from '@angular-devkit/core' ;
15
22
import { NodeJsSyncHost , createConsoleLogger } from '@angular-devkit/core/node' ;
16
23
import { of } from 'rxjs' ;
17
24
import { from } from 'rxjs' ;
@@ -88,8 +95,29 @@ export abstract class ArchitectCommand extends Command<ArchitectCommandOptions>
88
95
const projectNames = this . getProjectNamesByTarget ( this . target ) ;
89
96
const { overrides } = this . _makeTargetSpecifier ( options ) ;
90
97
if ( projectNames . length > 1 && Object . keys ( overrides || { } ) . length > 0 ) {
91
- throw new Error ( 'Architect commands with multiple targets cannot specify overrides.'
92
- + `'${ this . target } ' would be run on the following projects: ${ projectNames . join ( ) } ` ) ;
98
+ // Verify that all builders are the same, otherwise error out (since the meaning of an
99
+ // option could vary from builder to builder).
100
+
101
+ const builders : string [ ] = [ ] ;
102
+ for ( const projectName of projectNames ) {
103
+ const targetSpec : TargetSpecifier = this . _makeTargetSpecifier ( options ) ;
104
+ const targetDesc = this . _architect . getBuilderConfiguration ( {
105
+ project : projectName ,
106
+ target : targetSpec . target ,
107
+ } ) ;
108
+
109
+ if ( builders . indexOf ( targetDesc . builder ) == - 1 ) {
110
+ builders . push ( targetDesc . builder ) ;
111
+ }
112
+ }
113
+
114
+ if ( builders . length > 1 ) {
115
+ throw new Error ( tags . oneLine `
116
+ Architect commands with command line overrides cannot target different builders. The
117
+ '${ this . target } ' target would run on projects ${ projectNames . join ( ) } which have the
118
+ following builders: ${ '\n ' + builders . join ( '\n ' ) }
119
+ ` ) ;
120
+ }
93
121
}
94
122
}
95
123
0 commit comments