@@ -12,7 +12,7 @@ export interface Device {
1212 getUuid ( ) : Device . UUID
1313 buildList ( ) : FullDeployedImageOptions
1414 buildIni ( ) : Record < string , string | undefined >
15- toIniString ( ) : Promise < string >
15+ toIniString ( ) : string
1616 deploy ( ) : Promise < void >
1717 delete ( ) : Promise < void >
1818 isDeployed ( ) : Promise < boolean >
@@ -204,13 +204,27 @@ export class DeviceImpl implements Device {
204204 return ini
205205 }
206206
207- async toIniString ( ) : Promise < string > {
207+ toIniString ( ) : string {
208208 return `${ Object . entries ( this . buildIni ( ) )
209209 . filter ( ( [ , value ] ) => value !== undefined && value !== null )
210210 . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
211211 . join ( '\n' ) } \n`
212212 }
213213
214+ buildDeviceIni ( ) : Record < string , string | undefined > {
215+ return {
216+ 'hvd.ini.encoding' : 'UTF-8' ,
217+ 'path' : this . buildList ( ) . path ,
218+ }
219+ }
220+
221+ buildDeviceIniString ( ) : string {
222+ return `${ Object . entries ( this . buildDeviceIni ( ) )
223+ . filter ( ( [ , value ] ) => value !== undefined && value !== null )
224+ . map ( ( [ key , value ] ) => `${ key } =${ value } ` )
225+ . join ( '\n' ) } \n`
226+ }
227+
214228 async deploy ( ) : Promise < void > {
215229 if ( await this . isDeployed ( ) )
216230 return
@@ -234,12 +248,15 @@ export class DeviceImpl implements Device {
234248 throw new DeployError ( DeployError . Code . DEVICE_ALREADY_DEPLOYED , `Image ${ listConfig . name } already deployed in lists.json` )
235249 lists . push ( listConfig )
236250
237- // Write lists.json
238- fs . writeFileSync ( listsPath , JSON . stringify ( lists , null , 2 ) )
239-
240251 // Write config.ini
241252 fs . mkdirSync ( listConfig . path , { recursive : true } )
242- fs . writeFileSync ( path . join ( listConfig . path , 'config.ini' ) , await this . toIniString ( ) )
253+ fs . writeFileSync ( path . join ( listConfig . path , 'config.ini' ) , this . toIniString ( ) )
254+
255+ // write device info's ini file
256+ fs . writeFileSync ( path . join ( deployedPath , `${ this . options . name } .ini` ) , this . buildDeviceIniString ( ) )
257+
258+ // Write lists.json
259+ fs . writeFileSync ( listsPath , JSON . stringify ( lists , null , 2 ) )
243260 }
244261
245262 async delete ( ) : Promise < void > {
@@ -255,6 +272,7 @@ export class DeviceImpl implements Device {
255272 lists . splice ( index , 1 )
256273 fs . writeFileSync ( listsPath , JSON . stringify ( lists , null , 2 ) )
257274 fs . rmSync ( path . resolve ( this . buildList ( ) . path ) , { recursive : true } )
275+ fs . rmSync ( path . resolve ( deployedPath , `${ this . options . name } .ini` ) )
258276 }
259277
260278 async isDeployed ( ) : Promise < boolean > {
0 commit comments