@@ -51,27 +51,27 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
51
51
52
52
// Ensure that the host folder is clean and we won't override any files
53
53
files . forEach ( function ( file ) {
54
- if ( fs . existsSync ( path . join ( hostPath , file ) ) ) {
55
- console . error (
56
- '`' + file + '` already exists in your app folder. We cannot ' +
57
- 'continue as you would lose all the changes in that file or directory. ' +
58
- 'Please delete it (maybe make a copy for backup) and run this ' +
59
- 'command again.'
60
- ) ;
61
- process . exit ( 1 ) ;
62
- }
54
+ if ( fs . existsSync ( path . join ( hostPath , file ) ) ) {
55
+ console . error (
56
+ '`' + file + '` already exists in your app folder. We cannot ' +
57
+ 'continue as you would lose all the changes in that file or directory. ' +
58
+ 'Please delete it (maybe make a copy for backup) and run this ' +
59
+ 'command again.'
60
+ ) ;
61
+ process . exit ( 1 ) ;
62
+ }
63
63
} ) ;
64
64
65
65
// Copy the files over
66
66
fs . mkdirSync ( path . join ( hostPath , 'config' ) ) ;
67
67
fs . mkdirSync ( path . join ( hostPath , 'scripts' ) ) ;
68
68
69
69
files . forEach ( function ( file ) {
70
- console . log ( 'Copying ' + file + ' to ' + hostPath ) ;
71
- var content = fs . readFileSync ( path . join ( selfPath , file ) , 'utf8' ) ;
72
- // Remove license header
73
- content = content . replace ( / ^ \/ \* \* ( \* (? ! \/ ) | [ ^ * ] ) * \* \/ / , '' ) . trim ( ) + '\n' ;
74
- fs . writeFileSync ( path . join ( hostPath , file ) , content ) ;
70
+ console . log ( 'Copying ' + file + ' to ' + hostPath ) ;
71
+ var content = fs . readFileSync ( path . join ( selfPath , file ) , 'utf8' ) ;
72
+ // Remove license header
73
+ content = content . replace ( / ^ \/ \* \* ( \* (? ! \/ ) | [ ^ * ] ) * \* \/ / , '' ) . trim ( ) + '\n' ;
74
+ fs . writeFileSync ( path . join ( hostPath , file ) , content ) ;
75
75
} ) ;
76
76
console . log ( ) ;
77
77
@@ -82,8 +82,12 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
82
82
delete hostPackage . devDependencies [ 'react-scripts' ] ;
83
83
84
84
Object . keys ( selfPackage . dependencies ) . forEach ( function ( key ) {
85
- console . log ( 'Adding dependency: ' + key ) ;
86
- hostPackage . devDependencies [ key ] = selfPackage . dependencies [ key ] ;
85
+ // For some reason optionalDependencies end up in dependencies after install
86
+ if ( selfPackage . optionalDependencies [ key ] ) {
87
+ return ;
88
+ }
89
+ console . log ( 'Adding dependency: ' + key ) ;
90
+ hostPackage . devDependencies [ key ] = selfPackage . dependencies [ key ] ;
87
91
} ) ;
88
92
89
93
console . log ( 'Updating scripts' ) ;
@@ -94,8 +98,8 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi
94
98
95
99
console . log ( 'Writing package.json' ) ;
96
100
fs . writeFileSync (
97
- path . join ( hostPath , 'package.json' ) ,
98
- JSON . stringify ( hostPackage , null , 2 )
101
+ path . join ( hostPath , 'package.json' ) ,
102
+ JSON . stringify ( hostPackage , null , 2 )
99
103
) ;
100
104
console . log ( ) ;
101
105
0 commit comments