@@ -35,15 +35,15 @@ export abstract class ArchitectCommand<
35
35
target : string | undefined ;
36
36
missingTargetError : string | undefined ;
37
37
38
- public async initialize ( options : T & Arguments ) : Promise < void > {
39
- await super . initialize ( options ) ;
40
-
38
+ public async initialize ( options : T & Arguments ) : Promise < number | void > {
41
39
this . _registry = new json . schema . CoreSchemaRegistry ( ) ;
42
40
this . _registry . addPostTransform ( json . schema . transforms . addUndefinedDefaults ) ;
43
41
this . _registry . useXDeprecatedProvider ( msg => this . logger . warn ( msg ) ) ;
44
42
45
43
if ( ! this . workspace ) {
46
- throw new Error ( 'A workspace is required for an architect command.' ) ;
44
+ this . logger . fatal ( 'A workspace is required for this command.' ) ;
45
+
46
+ return 1 ;
47
47
}
48
48
49
49
this . _architectHost = new WorkspaceNodeModulesArchitectHost ( this . workspace , this . workspace . basePath ) ;
@@ -57,15 +57,19 @@ export abstract class ArchitectCommand<
57
57
58
58
const specifier = this . _makeTargetSpecifier ( options ) ;
59
59
if ( ! specifier . project || ! specifier . target ) {
60
- throw new Error ( 'Cannot determine project or target for command.' ) ;
60
+ this . logger . fatal ( 'Cannot determine project or target for command.' ) ;
61
+
62
+ return 1 ;
61
63
}
62
64
63
65
return ;
64
66
}
65
67
66
68
let projectName = options . project ;
67
69
if ( projectName && ! this . workspace . projects . has ( projectName ) ) {
68
- throw new Error ( `Project '${ projectName } ' does not exist.` ) ;
70
+ this . logger . fatal ( `Project '${ projectName } ' does not exist.` ) ;
71
+
72
+ return 1 ;
69
73
}
70
74
71
75
const commandLeftovers = options [ '--' ] ;
@@ -77,12 +81,16 @@ export abstract class ArchitectCommand<
77
81
}
78
82
79
83
if ( targetProjectNames . length === 0 ) {
80
- throw new Error ( this . missingTargetError || `No projects support the '${ this . target } ' target.` ) ;
84
+ this . logger . fatal ( this . missingTargetError || `No projects support the '${ this . target } ' target.` ) ;
85
+
86
+ return 1 ;
81
87
}
82
88
83
89
if ( projectName && ! targetProjectNames . includes ( projectName ) ) {
84
- throw new Error ( this . missingTargetError ||
90
+ this . logger . fatal ( this . missingTargetError ||
85
91
`Project '${ projectName } ' does not support the '${ this . target } ' target.` ) ;
92
+
93
+ return 1 ;
86
94
}
87
95
88
96
if ( ! projectName && commandLeftovers && commandLeftovers . length > 0 ) {
@@ -141,11 +149,13 @@ export abstract class ArchitectCommand<
141
149
}
142
150
143
151
if ( ! projectName && this . multiTarget && builderNames . size > 1 ) {
144
- throw new Error ( tags . oneLine `
152
+ this . logger . fatal ( tags . oneLine `
145
153
Architect commands with command line overrides cannot target different builders. The
146
154
'${ this . target } ' target would run on projects ${ targetProjectNames . join ( ) } which have the
147
155
following builders: ${ '\n ' + [ ...builderNames ] . join ( '\n ' ) }
148
156
` ) ;
157
+
158
+ return 1 ;
149
159
}
150
160
}
151
161
@@ -159,7 +169,9 @@ export abstract class ArchitectCommand<
159
169
// This is a special case where we just return.
160
170
return ;
161
171
} else {
162
- throw new Error ( this . missingTargetError || 'Cannot determine project or target for command.' ) ;
172
+ this . logger . fatal ( this . missingTargetError || 'Cannot determine project or target for command.' ) ;
173
+
174
+ return 1 ;
163
175
}
164
176
}
165
177
0 commit comments