@@ -58,7 +58,6 @@ export class PackageManager {
5858
5959 private packList : PackInfo [ ] ;
6060
61- private packRootDir : File | undefined ;
6261 private currentPackDir : File | undefined ;
6362 private project : AbstractProject ;
6463
@@ -134,27 +133,30 @@ export class PackageManager {
134133 }
135134
136135 Init ( ) {
137- /* set default pack root */
138- this . packRootDir = new File ( this . project . ToAbsolutePath ( PackageManager . PACK_DIR ) ) ;
139136
140137 /* if we have installed a pack, load and override old pack root */
141138 const prjConfig = this . project . GetConfiguration < ArmBaseCompileData > ( ) . config ;
142139 if ( prjConfig . packDir ) {
143140 const packDir = new File ( this . project . ToAbsolutePath ( prjConfig . packDir ) ) ;
144141 if ( packDir . IsDir ( ) ) {
145- this . packRootDir = packDir ;
146142 const packManager = this . project . GetPackManager ( ) ;
147- packManager . LoadPackage ( this . packRootDir ) ;
148- const devName = prjConfig . deviceName ;
149- if ( devName ) {
150- packManager . SetDeviceInfo ( devName , prjConfig . compileConfig . cpuType ) ;
143+ try {
144+ packManager . LoadPackage ( packDir ) ;
145+ const devName = prjConfig . deviceName ;
146+ if ( devName ) {
147+ packManager . SetDeviceInfo ( devName , prjConfig . compileConfig . cpuType ) ;
148+ }
149+ } catch ( error ) {
150+ GlobalEvent . emit ( 'msg' , newMessage ( 'Error' , 'Fail to load chip package for this project !' ) ) ;
151+ GlobalEvent . log_error ( error ) ;
152+ GlobalEvent . log_show ( ) ;
151153 }
152154 }
153155 }
154156 }
155157
156- GetPackRootDir ( ) : File | undefined {
157- return this . packRootDir ;
158+ private packRootDir ( ) : File {
159+ return File . from ( this . project . ToAbsolutePath ( PackageManager . PACK_DIR ) ) ;
158160 }
159161
160162 GetPackDir ( ) : File | undefined {
@@ -317,13 +319,9 @@ export class PackageManager {
317319 }
318320
319321 private ClearAll ( ) {
320-
321- if ( this . packRootDir && this . packRootDir . IsDir ( ) ) {
322- DeleteDir ( this . packRootDir ) ;
322+ if ( this . packRootDir ( ) . IsDir ( ) ) {
323+ DeleteDir ( this . packRootDir ( ) ) ;
323324 }
324-
325- /* set default pack root */
326- this . packRootDir = new File ( this . project . ToAbsolutePath ( PackageManager . PACK_DIR ) ) ;
327325 }
328326
329327 private _checkConditionGroup ( gMap : ConditionMap ,
@@ -1188,7 +1186,7 @@ export class PackageManager {
11881186
11891187 async Install ( pack : File , reporter ?: ( progress ?: number , message ?: string ) => void ) : Promise < void > {
11901188
1191- const packDir : File = ( < File > this . packRootDir ) ;
1189+ const packDir : File = this . packRootDir ( ) ;
11921190
11931191 this . ClearAll ( ) ;
11941192 packDir . CreateDir ( true ) ;
0 commit comments