6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { virtualFs , workspaces } from '@angular-devkit/core' ;
9
- import { Rule , Tree } from '@angular-devkit/schematics' ;
9
+ import { Rule , Tree , noop } from '@angular-devkit/schematics' ;
10
10
import { ProjectType } from './workspace-models' ;
11
11
12
12
function createHost ( tree : Tree ) : workspaces . WorkspaceHost {
@@ -33,14 +33,14 @@ function createHost(tree: Tree): workspaces.WorkspaceHost {
33
33
}
34
34
35
35
export function updateWorkspace (
36
- updater : ( workspace : workspaces . WorkspaceDefinition ) => void | PromiseLike < void > ,
36
+ updater : ( workspace : workspaces . WorkspaceDefinition ) => void | Rule | PromiseLike < void | Rule > ,
37
37
) : Rule ;
38
38
export function updateWorkspace (
39
39
workspace : workspaces . WorkspaceDefinition ,
40
40
) : Rule ;
41
41
export function updateWorkspace (
42
42
updaterOrWorkspace : workspaces . WorkspaceDefinition
43
- | ( ( workspace : workspaces . WorkspaceDefinition ) => void | PromiseLike < void > ) ,
43
+ | ( ( workspace : workspaces . WorkspaceDefinition ) => void | Rule | PromiseLike < void | Rule > ) ,
44
44
) : Rule {
45
45
return async ( tree : Tree ) => {
46
46
const host = createHost ( tree ) ;
@@ -49,14 +49,15 @@ export function updateWorkspace(
49
49
50
50
const { workspace } = await workspaces . readWorkspace ( '/' , host ) ;
51
51
52
- const result = updaterOrWorkspace ( workspace ) ;
53
- if ( result !== undefined ) {
54
- await result ;
55
- }
52
+ const result = await updaterOrWorkspace ( workspace ) ;
56
53
57
54
await workspaces . writeWorkspace ( workspace , host ) ;
55
+
56
+ return result || noop ;
58
57
} else {
59
58
await workspaces . writeWorkspace ( updaterOrWorkspace , host ) ;
59
+
60
+ return noop ;
60
61
}
61
62
} ;
62
63
}
0 commit comments