@@ -111,6 +111,29 @@ export default class LimaBackend extends BaseBackend {
111111 } else {
112112 await this . downloadVM ( ) ;
113113
114+ const resourcesDir = path . join ( this . resourcePath , platform ) ;
115+ const tarPath = path . join ( resourcesDir , `lima-${ LIMA_VERSION } .tgz` ) ;
116+ const limaDir = path . join ( resourcesDir , "lima" ) ;
117+
118+ await fs . promises . mkdir ( limaDir , { recursive : true } ) ;
119+
120+ this . emit ( events . VM_INIT_OUTPUT , "Extracting virtual machine files" ) ;
121+
122+ const child = ChildProcess . spawn ( "/usr/bin/tar" , [ "-xf" , tarPath ] , {
123+ cwd : limaDir ,
124+ stdio : "inherit" ,
125+ } ) ;
126+
127+ await new Promise ( ( resolve , reject ) => {
128+ child . on ( "exit" , ( code , signal ) => {
129+ if ( code === 0 ) {
130+ resolve ( true ) ;
131+ } else {
132+ reject ( new Error ( `Lima extract failed with ${ code || signal } ` ) ) ;
133+ }
134+ } ) ;
135+ } ) ;
136+
114137 const config : LimaConfiguration = merge ( {
115138 arch : null ,
116139 images : await this . downloadVMImages ( ) ,
@@ -169,30 +192,14 @@ export default class LimaBackend extends BaseBackend {
169192
170193 const url = `${ LIMA_REPO } /${ LIMA_VERSION } /lima-and-qemu.${ platformName } ${ archName } .tar.gz` ;
171194 const resourcesDir = path . join ( this . resourcePath , platform ) ;
172- const limaDir = path . join ( resourcesDir , "lima" ) ;
195+
173196 const tarPath = path . join ( resourcesDir , `lima-${ LIMA_VERSION } .tgz` ) ;
174197
175198 this . emit ( events . VM_INIT_OUTPUT , `Downloading virtual machine` ) ;
176199
177200 await download ( url , tarPath ) ;
178- await fs . promises . mkdir ( limaDir , { recursive : true } ) ;
179201
180- this . emit ( events . VM_INIT_OUTPUT , "Extracting virtual machine files" ) ;
181-
182- const child = ChildProcess . spawn ( "/usr/bin/tar" , [ "-xf" , tarPath ] , {
183- cwd : limaDir ,
184- stdio : "inherit" ,
185- } ) ;
186-
187- return await new Promise ( ( resolve , reject ) => {
188- child . on ( "exit" , ( code , signal ) => {
189- if ( code === 0 ) {
190- resolve ( true ) ;
191- } else {
192- reject ( new Error ( `Lima extract failed with ${ code || signal } ` ) ) ;
193- }
194- } ) ;
195- } ) ;
202+ return true ;
196203 }
197204
198205 async downloadVMImages ( ) : Promise < VMImage [ ] > {
0 commit comments