File tree Expand file tree Collapse file tree 1 file changed +6
-18
lines changed
packages/angular_devkit/schematics/src/rules Expand file tree Collapse file tree 1 file changed +6
-18
lines changed Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { normalize } from '@angular-devkit/core' ;
9
- import { FileOperator , Rule } from '../engine/interface' ;
10
- import { FileEntry } from '../tree/interface' ;
11
- import { forEach } from './base' ;
9
+ import { Rule } from '../engine/interface' ;
12
10
13
11
14
- export function moveOp ( from : string , to ?: string ) : FileOperator {
12
+ export function move ( from : string , to ?: string ) : Rule {
15
13
if ( to === undefined ) {
16
14
to = from ;
17
15
from = '/' ;
@@ -20,19 +18,9 @@ export function moveOp(from: string, to?: string): FileOperator {
20
18
const fromPath = normalize ( '/' + from ) ;
21
19
const toPath = normalize ( '/' + to ) ;
22
20
23
- return ( entry : FileEntry ) => {
24
- if ( entry . path . startsWith ( fromPath ) ) {
25
- return {
26
- content : entry . content ,
27
- path : normalize ( toPath + '/' + entry . path . substr ( fromPath . length ) ) ,
28
- } ;
21
+ return tree => tree . visit ( path => {
22
+ if ( path . startsWith ( fromPath ) ) {
23
+ tree . rename ( path , toPath + '/' + path . substr ( fromPath . length ) ) ;
29
24
}
30
-
31
- return entry ;
32
- } ;
33
- }
34
-
35
-
36
- export function move ( from : string , to ?: string ) : Rule {
37
- return forEach ( moveOp ( from , to ) ) ;
25
+ } ) ;
38
26
}
You can’t perform that action at this time.
0 commit comments