@@ -140,7 +140,7 @@ export default {
140
140
this . $logger . trace (
141
141
"Project Config Service using legacy configuration..."
142
142
) ;
143
- if ( ! this . forceUsingLegacyConfig ) {
143
+ if ( ! this . forceUsingLegacyConfig && info . hasNSConfig ) {
144
144
this . warnUsingLegacyNSConfig ( ) ;
145
145
}
146
146
return this . fallbackToLegacyNSConfig ( info ) ;
@@ -329,31 +329,36 @@ export default {
329
329
// ignore if the file doesn't exist
330
330
}
331
331
332
- const packageJson = this . $fs . readJson (
333
- path . join ( this . projectHelper . projectDir , "package.json" )
334
- ) ;
332
+ try {
333
+ const packageJson = this . $fs . readJson (
334
+ path . join ( this . projectHelper . projectDir , "package.json" )
335
+ ) ;
335
336
336
- // add app id to additionalData for backwards compatibility
337
- if (
338
- ! NSConfig . id &&
339
- packageJson &&
340
- packageJson . nativescript &&
341
- packageJson . nativescript . id
342
- ) {
343
- const ids = packageJson . nativescript . id ;
344
- if ( typeof ids === "string" ) {
345
- additionalData . push ( {
346
- id : packageJson . nativescript . id ,
347
- } ) ;
348
- } else if ( typeof ids === "object" ) {
349
- for ( const platform of Object . keys ( ids ) ) {
337
+ // add app id to additionalData for backwards compatibility
338
+ if (
339
+ ! NSConfig . id &&
340
+ packageJson &&
341
+ packageJson . nativescript &&
342
+ packageJson . nativescript . id
343
+ ) {
344
+ const ids = packageJson . nativescript . id ;
345
+ if ( typeof ids === "string" ) {
350
346
additionalData . push ( {
351
- [ platform ] : {
352
- id : packageJson . nativescript . id [ platform ] ,
353
- } ,
347
+ id : packageJson . nativescript . id ,
354
348
} ) ;
349
+ } else if ( typeof ids === "object" ) {
350
+ for ( const platform of Object . keys ( ids ) ) {
351
+ additionalData . push ( {
352
+ [ platform ] : {
353
+ id : packageJson . nativescript . id [ platform ] ,
354
+ } ,
355
+ } ) ;
356
+ }
355
357
}
356
358
}
359
+ } catch ( err ) {
360
+ this . $logger . trace ( "failed to read package.json data for config" , err ) ;
361
+ // ignore if the file doesn't exist
357
362
}
358
363
359
364
return _ . defaultsDeep ( { } , ...additionalData , NSConfig ) ;
0 commit comments