@@ -22,6 +22,8 @@ const {
2222const { parseArgs} = require ( '@pkgjs/parseargs' ) ;
2323const chalk = require ( 'chalk' ) ;
2424const { execSync} = require ( 'child_process' ) ;
25+ const { promises : fs } = require ( 'fs' ) ;
26+ const path = require ( 'path' ) ;
2527
2628const config = {
2729 options : {
@@ -64,6 +66,10 @@ async function main() {
6466 }
6567
6668 await initNewProjectFromSource ( options ) ;
69+
70+ // TODO(T179377112): Fix memory leak from `spawn` in `setupVerdaccio` (above
71+ // kill command does not wait for kill success).
72+ process . exit ( 0 ) ;
6773}
6874
6975async function initNewProjectFromSource (
@@ -119,48 +125,44 @@ async function initNewProjectFromSource(
119125 {
120126 // Avoid loading packages/react-native/react-native.config.js
121127 cwd : REPO_ROOT ,
122- stdio : verbose ? 'inherit' : [ process . stderr ] ,
128+ stdio : 'inherit' ,
123129 } ,
124130 ) ;
125131 console . log ( '\nDone ✅' ) ;
126132
127133 console . log ( 'Installing project dependencies' ) ;
128- await runYarnUsingProxy ( directory ) ;
134+ await installProjectUsingProxy ( directory ) ;
129135 console . log ( 'Done ✅' ) ;
130136 } catch ( e ) {
131137 console . log ( 'Failed ❌' ) ;
132138 throw e ;
133139 } finally {
134140 console . log ( `Cleanup: Killing Verdaccio process (PID: ${ verdaccioPid } )` ) ;
135- execSync ( `kill -9 ${ verdaccioPid } ` ) ;
136- console . log ( 'Done ✅' ) ;
141+ try {
142+ execSync ( `kill -9 ${ verdaccioPid } ` ) ;
143+ console . log ( 'Done ✅' ) ;
144+ } catch {
145+ console . warn ( 'Failed to kill Verdaccio process' ) ;
146+ }
137147
138148 console . log ( 'Cleanup: Removing Verdaccio storage directory' ) ;
139149 execSync ( `rm -rf ${ VERDACCIO_STORAGE_PATH } ` ) ;
140150 console . log ( 'Done ✅' ) ;
141-
142- // TODO(huntie): Fix memory leak from `spawn` in `setupVerdaccio` (above
143- // kill command does not wait for kill success).
144- process . exit ( 0 ) ;
145151 }
146152}
147153
148- async function runYarnUsingProxy ( cwd /*: string */ ) {
154+ async function installProjectUsingProxy ( cwd /*: string */ ) {
149155 const execOptions = {
150156 cwd,
151157 stdio : 'inherit' ,
152158 } ;
153- execSync (
154- `yarn config set npmRegistryServer "${ VERDACCIO_SERVER_URL } "` ,
155- execOptions ,
156- ) ;
157- execSync (
158- 'yarn config set unsafeHttpWhitelist --json \'["localhost"]\'' ,
159- execOptions ,
160- ) ;
161159
162160 // TODO(huntie): Review pre-existing retry limit
163- const success = await retry ( 'yarn' , execOptions , 3 , 500 , [ 'install' ] ) ;
161+ const success = await retry ( 'npm' , execOptions , 3 , 500 , [
162+ 'install' ,
163+ '--registry' ,
164+ VERDACCIO_SERVER_URL ,
165+ ] ) ;
164166
165167 if ( ! success ) {
166168 throw new Error ( 'Failed to install project dependencies' ) ;
0 commit comments