We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0c4b4a6 commit 4f6b98dCopy full SHA for 4f6b98d
1 file changed
packages/angular_devkit/schematics/src/rules/move.ts
@@ -23,9 +23,17 @@ 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
+
37
+ return tree;
38
+ };
39
0 commit comments