66 * found in the LICENSE file at https://angular.io/license
77 */
88import { virtualFs , workspaces } from '@angular-devkit/core' ;
9- import { Rule , Tree } from '@angular-devkit/schematics' ;
9+ import { Rule , Tree , noop } from '@angular-devkit/schematics' ;
1010import { ProjectType } from './workspace-models' ;
1111
1212function createHost ( tree : Tree ) : workspaces . WorkspaceHost {
@@ -33,14 +33,14 @@ function createHost(tree: Tree): workspaces.WorkspaceHost {
3333}
3434
3535export function updateWorkspace (
36- updater : ( workspace : workspaces . WorkspaceDefinition ) => void | PromiseLike < void > ,
36+ updater : ( workspace : workspaces . WorkspaceDefinition ) => void | Rule | PromiseLike < void | Rule > ,
3737) : Rule ;
3838export function updateWorkspace (
3939 workspace : workspaces . WorkspaceDefinition ,
4040) : Rule ;
4141export function updateWorkspace (
4242 updaterOrWorkspace : workspaces . WorkspaceDefinition
43- | ( ( workspace : workspaces . WorkspaceDefinition ) => void | PromiseLike < void > ) ,
43+ | ( ( workspace : workspaces . WorkspaceDefinition ) => void | Rule | PromiseLike < void | Rule > ) ,
4444) : Rule {
4545 return async ( tree : Tree ) => {
4646 const host = createHost ( tree ) ;
@@ -49,14 +49,15 @@ export function updateWorkspace(
4949
5050 const { workspace } = await workspaces . readWorkspace ( '/' , host ) ;
5151
52- const result = updaterOrWorkspace ( workspace ) ;
53- if ( result !== undefined ) {
54- await result ;
55- }
52+ const result = await updaterOrWorkspace ( workspace ) ;
5653
5754 await workspaces . writeWorkspace ( workspace , host ) ;
55+
56+ return result || noop ;
5857 } else {
5958 await workspaces . writeWorkspace ( updaterOrWorkspace , host ) ;
59+
60+ return noop ;
6061 }
6162 } ;
6263}
0 commit comments