We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0c4b4a6 commit 0ea3c44Copy full SHA for 0ea3c44
1 file changed
packages/angular_devkit/schematics/src/rules/move.ts
@@ -23,9 +23,16 @@ export function move(from: string, to?: string): Rule {
23
return noop;
24
}
25
26
- return tree => tree.visit(path => {
27
- if (path.startsWith(fromPath)) {
28
- tree.rename(path, toPath + '/' + path.substr(fromPath.length));
+ return tree => {
+ if (tree.exists(fromPath)) {
+ // fromPath is a file
29
+ tree.rename(fromPath, toPath);
30
+ } else {
31
+ // fromPath is a directory
32
+ tree.getDir(fromPath).visit(path => {
33
+ tree.rename(path, toPath + '/' + path.substr(fromPath.length));
34
+ });
35
36
+ return tree;
37
});
38
0 commit comments