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 66 * found in the LICENSE file at https://angular.io/license
77 */
88import { 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' ;
1210
1311
14- export function moveOp ( from : string , to ?: string ) : FileOperator {
12+ export function move ( from : string , to ?: string ) : Rule {
1513 if ( to === undefined ) {
1614 to = from ;
1715 from = '/' ;
@@ -20,19 +18,9 @@ export function moveOp(from: string, to?: string): FileOperator {
2018 const fromPath = normalize ( '/' + from ) ;
2119 const toPath = normalize ( '/' + to ) ;
2220
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 ) ) ;
2924 }
30-
31- return entry ;
32- } ;
33- }
34-
35-
36- export function move ( from : string , to ?: string ) : Rule {
37- return forEach ( moveOp ( from , to ) ) ;
25+ } ) ;
3826}
You can’t perform that action at this time.
0 commit comments