1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.move = move;
|
11 | const core_1 = require("@angular-devkit/core");
|
12 | const base_1 = require("./base");
|
13 | function move(from, to) {
|
14 | if (to === undefined) {
|
15 | to = from;
|
16 | from = '/';
|
17 | }
|
18 | const fromPath = (0, core_1.normalize)('/' + from);
|
19 | const toPath = (0, core_1.normalize)('/' + to);
|
20 | if (fromPath === toPath) {
|
21 | return base_1.noop;
|
22 | }
|
23 | return (tree) => {
|
24 | if (tree.exists(fromPath)) {
|
25 |
|
26 | tree.rename(fromPath, toPath);
|
27 | }
|
28 | else {
|
29 |
|
30 | tree.getDir(fromPath).visit((path) => {
|
31 | tree.rename(path, (0, core_1.join)(toPath, path.slice(fromPath.length)));
|
32 | });
|
33 | }
|
34 | return tree;
|
35 | };
|
36 | }
|