@@ -9,31 +9,29 @@ const devDependencies = require('./devDependencies.json');
9
9
const deleteFile = ( fileName ) => fs . unlinkSync ( path . join ( process . cwd ( ) , fileName ) ) ;
10
10
const writeFile = ( fileName , data ) => fs . writeFileSync ( path . join ( process . cwd ( ) , fileName ) , data ) ;
11
11
const isYarnAvailable = ( ) => {
12
- try {
13
- execSync ( 'yarnpkg --version' , { stdio : 'ignore' } ) ;
14
- return true ;
15
- } catch ( e ) {
16
- return false ;
17
- }
18
- }
19
- const currPackager = isYarnAvailable ? "yarn" : "npm" ;
20
- const logInstallingWith = pkg => console . log ( `\n📦 Installing dependencies with ${ pkg } ...\n` ) ;
21
- const execOptions = {
22
- stdio : 'inherit'
12
+ try {
13
+ execSync ( 'yarnpkg --version' , { stdio : 'ignore' } ) ;
14
+ return true ;
15
+ } catch ( e ) {
16
+ return false ;
17
+ }
23
18
}
24
19
20
+ const packager = isYarnAvailable ( ) ? 'yarn' : 'npm' ;
21
+ const execOptions = { stdio : 'inherit' } ;
22
+
25
23
console . log ( '\n🔄 Please wait...\n' ) ;
26
24
27
25
packageJson . scripts . start = `${ packageJson . scripts . start } --config ../../../../rn-cli.config.js` ;
28
26
packageJson . jest = Object . assign ( packageJson . jest , jestJson ) ;
29
27
writeFile ( 'package.json' , JSON . stringify ( packageJson , null , 2 ) ) ;
30
28
31
- logInstallingWith ( currPackager ) ;
29
+ console . log ( `\n📦 Installing dependencies with ${ packager } ...\n` ) ;
32
30
33
- if ( isYarnAvailable ) {
34
- execSync ( `yarn add ${ devDependencies . join ( ' ' ) } --dev --exact` , execOptions ) ;
31
+ if ( packager === 'yarn' ) {
32
+ execSync ( `yarn add ${ devDependencies . join ( ' ' ) } --dev --exact` , execOptions ) ;
35
33
} else {
36
- execSync ( `npm i ${ devDependencies . join ( ' ' ) } --save-dev --save-exact` , execOptions ) ;
34
+ execSync ( `npm i ${ devDependencies . join ( ' ' ) } --save-dev --save-exact` , execOptions ) ;
37
35
}
38
36
39
37
deleteFile ( 'App.js' ) ;
@@ -45,4 +43,4 @@ deleteFile('README.md');
45
43
deleteFile ( 'LICENSE' ) ;
46
44
deleteFile ( 'setup.js' ) ;
47
45
48
- console . log ( `\n✅ Setup completed! You can now start with: ${ currPackager } start\n` ) ;
46
+ console . log ( `\n✅ Setup completed! You can now start with: ${ packager } start\n` ) ;
0 commit comments