File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ng } from '../../../utils/process' ;
2
+ import { rename } from '../../../utils/fs' ;
3
+
4
+ export default function ( ) {
5
+ return Promise . resolve ( )
6
+ . then ( ( ) => ng ( 'get' , 'apps.0.appRoot' ) )
7
+ . then ( ( { stdout } ) => {
8
+ if ( ! stdout . match ( / a p p / ) ) {
9
+ throw new Error ( `Expected "app", received "${ JSON . stringify ( stdout ) } ".` ) ;
10
+ }
11
+ } )
12
+ . then ( ( ) => ng ( 'set' , 'apps.0.appRoot' , 'app1' ) )
13
+ . then ( ( ) => ng ( 'get' , 'apps.0.appRoot' ) )
14
+ . then ( ( { stdout } ) => {
15
+ if ( ! stdout . match ( / a p p 1 / ) ) {
16
+ throw new Error ( `Expected "app1", received "${ JSON . stringify ( stdout ) } ".` ) ;
17
+ }
18
+ } )
19
+ . then ( ( ) => rename ( './src/app' , './src/app1' ) )
20
+ . then ( ( ) => ng ( 'g' , 'c' , 'hello' , '-d' ) )
21
+ . then ( ( { stdout } ) => {
22
+ if ( ! stdout . match ( / a p p 1 / ) ) {
23
+ throw new Error ( `Expected "app", received "${ JSON . stringify ( stdout ) } ".` ) ;
24
+ }
25
+ } ) ;
26
+ }
Original file line number Diff line number Diff line change @@ -71,6 +71,17 @@ export function createDir(path: string) {
71
71
_recursiveMkDir ( path ) ;
72
72
}
73
73
74
+ export function rename ( from : string , to : string ) {
75
+ return new Promise ( ( resolve , reject ) => {
76
+ fs . rename ( from , to , ( error ) => {
77
+ if ( error ) {
78
+ reject ( error ) ;
79
+ } else {
80
+ resolve ( ) ;
81
+ }
82
+ } ) ;
83
+ } ) ;
84
+ }
74
85
75
86
function _recursiveMkDir ( path : string ) {
76
87
if ( fs . existsSync ( path ) ) {
You can’t perform that action at this time.
0 commit comments