MCPcopy
hub / github.com/angular/angular-cli / move

Function move

packages/angular_devkit/schematics/src/rules/move.ts:15–41  ·  view source on GitHub ↗
(from: string, to?: string)

Source from the content-addressed store, hash-verified

13export function move(from: string, to: string): Rule;
14export function move(to: string): Rule;
15export function move(from: string, to?: string): Rule {
16 if (to === undefined) {
17 to = from;
18 from = '/';
19 }
20
21 const fromPath = normalize('/' + from);
22 const toPath = normalize('/' + to);
23
24 if (fromPath === toPath) {
25 return noop;
26 }
27
28 return (tree) => {
29 if (tree.exists(fromPath)) {
30 // fromPath is a file
31 tree.rename(fromPath, toPath);
32 } else {
33 // fromPath is a directory
34 tree.getDir(fromPath).visit((path) => {
35 tree.rename(path, join(toPath, path.slice(fromPath.length)));
36 });
37 }
38
39 return tree;
40 };
41}

Callers 15

index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
generateFromFilesFunction · 0.90
addServerFileFunction · 0.90
index.tsFile · 0.90
index.tsFile · 0.90
index.tsFile · 0.90

Calls 6

normalizeFunction · 0.90
joinFunction · 0.90
existsMethod · 0.65
renameMethod · 0.65
visitMethod · 0.65
getDirMethod · 0.65

Tested by

no test coverage detected