@@ -16,9 +16,8 @@ import {
16
16
formats ,
17
17
workflow ,
18
18
} from '@angular-devkit/schematics' ; // tslint:disable-line:no-implicit-dependencies
19
- import { EMPTY , Observable , Subject , concat , of , throwError } from 'rxjs' ;
20
- import { reduce , tap } from 'rxjs/internal/operators' ;
21
- import { concatMap , ignoreElements , map } from 'rxjs/operators' ;
19
+ import { Observable , Subject , concat , of , throwError } from 'rxjs' ;
20
+ import { concatMap , defaultIfEmpty , ignoreElements , last , map , tap } from 'rxjs/operators' ;
22
21
import { NodeModulesEngineHost , validateOptionsWithSchema } from '..' ;
23
22
import { DryRunEvent } from '../../src/sink/dryrun' ;
24
23
import { BuiltinTaskExecutor } from '../../tasks/node' ;
@@ -129,54 +128,52 @@ export class NodeWorkflow implements workflow.Workflow {
129
128
} ;
130
129
this . _context . push ( context ) ;
131
130
132
- return concat (
133
- schematic . call ( options . options , of ( new HostTree ( this . _host ) ) , {
134
- logger : context . logger ,
135
- } ) . pipe (
136
- map ( tree => Tree . optimize ( tree ) ) ,
137
- concatMap ( ( tree : Tree ) => {
138
- return concat (
139
- dryRunSink . commit ( tree ) . pipe (
140
- ignoreElements ( ) ,
141
- ) ,
142
- of ( tree ) ,
143
- ) ;
144
- } ) ,
145
- concatMap ( ( tree : Tree ) => {
146
- dryRunSubscriber . unsubscribe ( ) ;
147
- if ( error ) {
148
- return throwError ( new UnsuccessfulWorkflowExecution ( ) ) ;
149
- }
150
- if ( this . _options . dryRun ) {
151
- return EMPTY ;
152
- }
153
-
154
- return fsSink . commit ( tree ) ;
155
- } ) ,
156
- ) ,
157
- concat ( new Observable < void > ( obs => {
158
- if ( ! this . _options . dryRun ) {
159
- this . _lifeCycle . next ( { kind : 'post-tasks-start' } ) ;
160
- this . _engine . executePostTasks ( )
161
- . pipe (
162
- reduce ( ( ) => { } ) ,
163
- tap ( ( ) => this . _lifeCycle . next ( { kind : 'post-tasks-end' } ) ) ,
164
- )
165
- . subscribe ( obs ) ;
166
- } else {
167
- obs . complete ( ) ;
131
+ return schematic . call (
132
+ options . options ,
133
+ of ( new HostTree ( this . _host ) ) ,
134
+ { logger : context . logger } ,
135
+ ) . pipe (
136
+ map ( tree => Tree . optimize ( tree ) ) ,
137
+ concatMap ( ( tree : Tree ) => {
138
+ return concat (
139
+ dryRunSink . commit ( tree ) . pipe ( ignoreElements ( ) ) ,
140
+ of ( tree ) ,
141
+ ) ;
142
+ } ) ,
143
+ concatMap ( ( tree : Tree ) => {
144
+ dryRunSubscriber . unsubscribe ( ) ;
145
+ if ( error ) {
146
+ return throwError ( new UnsuccessfulWorkflowExecution ( ) ) ;
147
+ }
148
+
149
+ if ( this . _options . dryRun ) {
150
+ return of ( ) ;
151
+ }
152
+
153
+ return fsSink . commit ( tree ) . pipe ( last ( ) , defaultIfEmpty ( ) ) ;
154
+ } ) ,
155
+ concatMap ( ( ) => {
156
+ if ( this . _options . dryRun ) {
157
+ return of ( ) ;
168
158
}
169
- } ) ) ,
170
- concat ( new Observable ( obs => {
159
+
160
+ this . _lifeCycle . next ( { kind : 'post-tasks-start' } ) ;
161
+
162
+ return this . _engine . executePostTasks ( )
163
+ . pipe (
164
+ tap ( { complete : ( ) => this . _lifeCycle . next ( { kind : 'post-tasks-end' } ) } ) ,
165
+ last ( ) ,
166
+ defaultIfEmpty ( ) ,
167
+ ) ;
168
+ } ) ,
169
+ tap ( { complete : ( ) => {
171
170
this . _lifeCycle . next ( { kind : 'workflow-end' } ) ;
172
171
this . _context . pop ( ) ;
173
172
174
173
if ( this . _context . length == 0 ) {
175
174
this . _lifeCycle . next ( { kind : 'end' } ) ;
176
175
}
177
-
178
- obs . complete ( ) ;
179
- } ) ) ,
180
- ) . pipe ( reduce ( ( ) => { } ) ) ;
176
+ } } ) ,
177
+ ) ;
181
178
}
182
179
}
0 commit comments