Skip to content

Commit 0c331c1

Browse files
amcdnlandrewseguin
authored andcommitted
fix(schematics): remove temp path #11198 (#11424)
* fix(schematics): remove temp path #11198 * chore: remove console * chore: pr nit
1 parent 4db95a9 commit 0c331c1

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/lib/schematics/update/update.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,15 @@ export default function(): Rule {
8181
// Delete the temporary schematics directory.
8282
context.addTask(
8383
new RunSchematicTask('ng-post-update', {
84-
deleteFiles: updateSrcs
85-
.map(entry => entry.path.replace(schematicsSrcPath, schematicsTmpPath))
84+
deletePath: schematicsTmpPath
8685
}), [upgradeTask]);
8786
};
8887
}
8988

9089
/** 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 {
9291
return (tree: Tree, context: SchematicContext) => {
93-
for (let file of options.deleteFiles) {
94-
tree.delete(file);
95-
}
96-
92+
tree.delete(options.deletePath);
9793
context.addTask(new RunSchematicTask('ng-post-post-update', {}));
9894
};
9995
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
});

0 commit comments

Comments
 (0)