File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
src/lib/schematics/update Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -81,19 +81,15 @@ export default function(): Rule {
81
81
// Delete the temporary schematics directory.
82
82
context . addTask (
83
83
new RunSchematicTask ( 'ng-post-update' , {
84
- deleteFiles : updateSrcs
85
- . map ( entry => entry . path . replace ( schematicsSrcPath , schematicsTmpPath ) )
84
+ deletePath : schematicsTmpPath
86
85
} ) , [ upgradeTask ] ) ;
87
86
} ;
88
87
}
89
88
90
89
/** Post-update schematic to be called when ng update is finished. */
91
- export function postUpdate ( options : { deleteFiles : string [ ] } ) : Rule {
90
+ export function postUpdate ( options : { deletePath : string } ) : Rule {
92
91
return ( tree : Tree , context : SchematicContext ) => {
93
- for ( let file of options . deleteFiles ) {
94
- tree . delete ( file ) ;
95
- }
96
-
92
+ tree . delete ( options . deletePath ) ;
97
93
context . addTask ( new RunSchematicTask ( 'ng-post-post-update' , { } ) ) ;
98
94
} ;
99
95
}
Original file line number Diff line number Diff line change
1
+ import { SchematicTestRunner } from '@angular-devkit/schematics/testing' ;
2
+ import { join } from 'path' ;
3
+ import { Tree } from '@angular-devkit/schematics' ;
4
+ import { createTestApp } from '../utils/testing' ;
5
+ import { getFileContent } from '@schematics/angular/utility/test' ;
6
+
7
+ const collectionPath = join ( __dirname , '../collection.json' ) ;
8
+
9
+ describe ( 'material-nav-schematic' , ( ) => {
10
+ let runner : SchematicTestRunner ;
11
+
12
+ beforeEach ( ( ) => {
13
+ runner = new SchematicTestRunner ( 'schematics' , collectionPath ) ;
14
+ } ) ;
15
+
16
+ it ( 'should remove the temp directory' , ( ) => {
17
+ const tree = runner . runSchematic ( 'update' , { } , createTestApp ( ) ) ;
18
+ const files = tree . files ;
19
+ expect ( files . find ( file => file . includes ( 'angular_material_schematics-' ) ) ) . toBeTruthy ( ) ;
20
+ } ) ;
21
+
22
+ } ) ;
You can’t perform that action at this time.
0 commit comments