Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 | /**
|
---|
| 3 | * @license
|
---|
| 4 | * Copyright Google LLC All Rights Reserved.
|
---|
| 5 | *
|
---|
| 6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 7 | * found in the LICENSE file at https://angular.io/license
|
---|
| 8 | */
|
---|
| 9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 10 | exports.move = void 0;
|
---|
| 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 = core_1.normalize('/' + from);
|
---|
| 19 | const toPath = core_1.normalize('/' + to);
|
---|
| 20 | if (fromPath === toPath) {
|
---|
| 21 | return base_1.noop;
|
---|
| 22 | }
|
---|
| 23 | return (tree) => {
|
---|
| 24 | if (tree.exists(fromPath)) {
|
---|
| 25 | // fromPath is a file
|
---|
| 26 | tree.rename(fromPath, toPath);
|
---|
| 27 | }
|
---|
| 28 | else {
|
---|
| 29 | // fromPath is a directory
|
---|
| 30 | tree.getDir(fromPath).visit((path) => {
|
---|
| 31 | tree.rename(path, core_1.join(toPath, path.substr(fromPath.length)));
|
---|
| 32 | });
|
---|
| 33 | }
|
---|
| 34 | return tree;
|
---|
| 35 | };
|
---|
| 36 | }
|
---|
| 37 | exports.move = move;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.